Extract music shuffle and repeat states and set the song progress to auto-update. (#554)
This commit is contained in:
parent
a26563d6c7
commit
23f2dd35d4
|
@ -51,6 +51,7 @@ public class MusicPlaybackReceiver extends BroadcastReceiver {
|
|||
stateSpec.position = ((Long) incoming).intValue() / 1000;
|
||||
} else if (incoming instanceof Boolean && "playing".equals(key)) {
|
||||
stateSpec.state = (byte) (((Boolean) incoming) ? MusicStateSpec.STATE_PLAYING : MusicStateSpec.STATE_PAUSED);
|
||||
stateSpec.playRate = (byte) (((Boolean) incoming) ? 100 : 0);
|
||||
} else if (incoming instanceof String && "duration".equals(key)) {
|
||||
musicSpec.duration = Integer.valueOf((String) incoming) / 1000;
|
||||
} else if (incoming instanceof String && "trackno".equals(key)) {
|
||||
|
@ -59,6 +60,18 @@ public class MusicPlaybackReceiver extends BroadcastReceiver {
|
|||
musicSpec.trackCount = Integer.valueOf((String) incoming);
|
||||
} else if (incoming instanceof Integer && "pos".equals(key)) {
|
||||
stateSpec.position = (Integer) incoming;
|
||||
} else if (incoming instanceof Integer && "repeat".equals(key)) {
|
||||
if ((Integer) incoming > 0) {
|
||||
stateSpec.repeat = 1;
|
||||
} else {
|
||||
stateSpec.repeat = 0;
|
||||
}
|
||||
} else if (incoming instanceof Integer && "shuffle".equals(key)) {
|
||||
if ((Integer) incoming > 0) {
|
||||
stateSpec.shuffle = 1;
|
||||
} else {
|
||||
stateSpec.shuffle = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ public class MusicStateSpec {
|
|||
public static final int STATE_UNKNOWN = 3;
|
||||
|
||||
public byte state;
|
||||
public int position;
|
||||
public int playRate;
|
||||
public int position; // Position of the current media in seconds
|
||||
public int playRate; // Speed of playback, usually 0 or 100 (full speed)
|
||||
public byte shuffle;
|
||||
public byte repeat;
|
||||
|
||||
|
@ -47,8 +47,8 @@ public class MusicStateSpec {
|
|||
@Override
|
||||
public int hashCode() {
|
||||
int result = (int) state;
|
||||
// ignore the position -- it is taken into account in equals()
|
||||
// result = 31 * result + position;
|
||||
//ignore the position -- it is taken into account in equals()
|
||||
//result = 31 * result + position;
|
||||
result = 31 * result + playRate;
|
||||
result = 31 * result + (int) shuffle;
|
||||
result = 31 * result + (int) repeat;
|
||||
|
|
|
@ -163,7 +163,8 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
|||
"com.android.music.playbackcomplete",
|
||||
"net.sourceforge.subsonic.androidapp.EVENT_META_CHANGED",
|
||||
"com.maxmpz.audioplayer.TPOS_SYNC",
|
||||
"com.maxmpz.audioplayer.STATUS_CHANGED",};
|
||||
"com.maxmpz.audioplayer.STATUS_CHANGED",
|
||||
"com.maxmpz.audioplayer.PLAYING_MODE_CHANGED"};
|
||||
|
||||
/**
|
||||
* For testing!
|
||||
|
|
Loading…
Reference in New Issue