Android Open Source - speedofsound Base Player






From Project

Back to project page speedofsound.

License

The source code is released under:

GNU General Public License

If you think the Android project speedofsound listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package net.codechunk.speedofsound.players;
//w w w  .java2  s  .  c  om
import net.codechunk.speedofsound.util.SongInfo;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;

public abstract class BasePlayer extends BroadcastReceiver
{
  private static final String TAG = "BasePlayer";

  public static final String PLAYBACK_CHANGED_BROADCAST = "playback-changed";

  public static final String PLAYBACK_STOPPED_BROADCAST = "playback-stopped";

  protected enum PlaybackAction
  {
    CHANGED, STOPPED, PAUSED, RESUMED
  }

  public abstract PlaybackAction getPlaybackAction(Context context, Intent intent);

  public abstract SongInfo getSongInfo(Context context, Intent intent);

  @Override
  public void onReceive(Context context, Intent intent)
  {
    Log.v(TAG, "Playback broadcast received: " + intent.getAction());

    // get the action from the player
    PlaybackAction action = getPlaybackAction(context, intent);

    LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
    if (action == PlaybackAction.CHANGED)
    {
      Log.d(TAG, "Sending song change broadcast");

      // get the track info from the player
      SongInfo info = this.getSongInfo(context, intent);

      // send out a broadcast with the details
      Intent broadcast = new Intent(BasePlayer.PLAYBACK_CHANGED_BROADCAST);
      broadcast.putExtra("track", info.track == null ? "Unknown" : info.track);
      broadcast.putExtra("artist", info.artist == null ? "Unknown" : info.artist);
      broadcast.putExtra("album", info.album == null ? "Unknown" : info.album);
      lbm.sendBroadcast(broadcast);
    }
    else if (action == PlaybackAction.STOPPED)
    {
      Log.d(TAG, "Sending playback stopped broadcast");

      Intent broadcast = new Intent(BasePlayer.PLAYBACK_STOPPED_BROADCAST);
      lbm.sendBroadcast(broadcast);
    }
  }

}




Java Source Code List

net.codechunk.speedofsound.LocaleActivity.java
net.codechunk.speedofsound.MapperActivity.java
net.codechunk.speedofsound.PreferencesActivity.java
net.codechunk.speedofsound.SongTracker.java
net.codechunk.speedofsound.SpeedActivity.java
net.codechunk.speedofsound.players.AndroidMusicPlayer.java
net.codechunk.speedofsound.players.BasePlayer.java
net.codechunk.speedofsound.players.HTCPlayer.java
net.codechunk.speedofsound.players.LastFmAPIPlayer.java
net.codechunk.speedofsound.players.SLSAPIPlayer.java
net.codechunk.speedofsound.players.SamsungPlayer.java
net.codechunk.speedofsound.players.WinampPlayer.java
net.codechunk.speedofsound.service.SoundServiceManager.java
net.codechunk.speedofsound.service.SoundService.java
net.codechunk.speedofsound.service.VolumeConversion.java
net.codechunk.speedofsound.service.VolumeThread.java
net.codechunk.speedofsound.util.AppPreferences.java
net.codechunk.speedofsound.util.AverageSpeed.java
net.codechunk.speedofsound.util.ColorCreator.java
net.codechunk.speedofsound.util.SliderPreference.java
net.codechunk.speedofsound.util.SongInfo.java
net.codechunk.speedofsound.util.SpeedConversions.java
net.codechunk.speedofsound.util.SpeedSliderPreference.java