@@ -0,0 +1,2528 @@
+/**%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A * %0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *     %0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage com.adam.aslfms.receiver;%0A%0Aimport android.content.Context;%0Aimport android.os.Bundle;%0Aimport android.util.Log;%0A%0Aimport com.adam.aslfms.util.Track;%0Aimport com.adam.aslfms.util.Util;%0A%0A/**%0A * A BroadcastReceiver for intents sent by the SoundCloud application%0A *%0A * @see AbstractPlayStatusReceiver%0A *%0A * @author Malachi Soord %3Cinverse.chi@gmail.com%3E%0A * @since 1.4.8%0A */%0Apublic class SoundCloudReceiver extends AbstractPlayStatusReceiver %7B%0A%0A%09// TODO: Get intents with full Strings.%0A%09// current limit is about 40 characters long.%0A%0A%09static final String APP_PACKAGE = %22com.soundcloud.android%22;%0A%09static final String APP_NAME = %22SoundCloud%22;%0A%0A%09public static final String ACTION_ANDROID_PLAYSTATECHANGED = %22com.android.music.playstatechanged%22;%0A%09public static final String ACTION_ANDROID_METACHANGED = %22com.android.music.metachanged%22;%0A%0A%09static final String TAG = %22SoundCloud%22;%0A%0A%09@Override%0A%09protected void parseIntent(Context ctx, String action, Bundle bundle) %7B%0A%0A%09%09MusicAPI musicAPI = MusicAPI.fromReceiver(ctx, APP_NAME, APP_PACKAGE,%0A%09%09%09%09null, false);%0A%09%09setMusicAPI(musicAPI);%0A%0A%09%09if (action.equals(ACTION_ANDROID_METACHANGED)) %7B%0A%09%09%09setState(Track.State.CHANGED);%0A%09%09%09Track.Builder b = new Track.Builder();%0A%09%09%09b.setMusicAPI(musicAPI);%0A%09%09%09b.setWhen(Util.currentTimeSecsUTC());%0A%0A%09%09%09// TODO: Work out correct parsing of artist/track if we get intents%0A%09%09%09// with full SoundCloud Strings%0A%0A%09%09%09b.setArtist(bundle.getString(%22artist%22));%0A%09%09%09b.setTrack(bundle.getString(%22track%22));%0A%09%09%09b.setDuration((bundle.getInt(%22duration%22) / 1000));%0A%09%09%09Log.e(TAG, %22Track length: %22 + String.valueOf(bundle.getInt(%22duration%22) / 1000));%0A%09%09%09setTrack(b.build());%0A%0A%09%09%7D else if (action.equals(ACTION_ANDROID_PLAYSTATECHANGED)) %7B%0A%09%09%09boolean playing = bundle.getBoolean(%22playing%22, false);%0A%09%09%09if (playing) %7B%0A%09%09%09%09setState(Track.State.RESUME);%0A%09%09%09%09Log.e(TAG, %22Setting state to RESUME%22);%0A%09%09%09%7D else if (!playing) %7B%0A%09%09%09%09setState(Track.State.PAUSE);%0A%09%09%09%09Log.e(TAG, %22Setting state to PAUSE%22);%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%7D%0A

Create SoundCloudReceiver.java