-Added persisting settings when switching between players.
This commit is contained in:
parent
0806344ffb
commit
052c9a9869
|
@ -216,7 +216,7 @@ public final class BackgroundPlayer extends Service {
|
|||
remoteViews.setOnClickPendingIntent(R.id.notificationFForward,
|
||||
PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_FAST_FORWARD), PendingIntent.FLAG_UPDATE_CURRENT));
|
||||
|
||||
setRepeatModeIcon(remoteViews, basePlayerImpl.simpleExoPlayer.getRepeatMode());
|
||||
setRepeatModeIcon(remoteViews, basePlayerImpl.getRepeatMode());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -489,7 +489,7 @@ public final class BackgroundPlayer extends Service {
|
|||
|
||||
private void updatePlayback() {
|
||||
if (activityListener != null && simpleExoPlayer != null && playQueue != null) {
|
||||
activityListener.onPlaybackUpdate(currentState, simpleExoPlayer.getRepeatMode(), playQueue.isShuffled(), simpleExoPlayer.getPlaybackParameters());
|
||||
activityListener.onPlaybackUpdate(currentState, getRepeatMode(), playQueue.isShuffled(), getPlaybackParameters());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -255,14 +255,17 @@ public abstract class BasePlayer implements Player.EventListener,
|
|||
return;
|
||||
}
|
||||
|
||||
setPlaybackSpeed(intent.getFloatExtra(PLAYBACK_SPEED, getPlaybackSpeed()));
|
||||
setPlaybackPitch(intent.getFloatExtra(PLAYBACK_PITCH, getPlaybackPitch()));
|
||||
final int repeatMode = intent.getIntExtra(REPEAT_MODE, getRepeatMode());
|
||||
final float playbackSpeed = intent.getFloatExtra(PLAYBACK_SPEED, getPlaybackSpeed());
|
||||
final float playbackPitch = intent.getFloatExtra(PLAYBACK_PITCH, getPlaybackPitch());
|
||||
|
||||
// Re-initialization
|
||||
destroyPlayer();
|
||||
if (playQueue != null) playQueue.dispose();
|
||||
if (playbackManager != null) playbackManager.dispose();
|
||||
initPlayer();
|
||||
setRepeatMode(repeatMode);
|
||||
setPlaybackParameters(playbackSpeed, playbackPitch);
|
||||
|
||||
// Good to go...
|
||||
initPlayback(this, queue);
|
||||
|
@ -534,7 +537,7 @@ public abstract class BasePlayer implements Player.EventListener,
|
|||
|
||||
final int mode;
|
||||
|
||||
switch (simpleExoPlayer.getRepeatMode()) {
|
||||
switch (getRepeatMode()) {
|
||||
case Player.REPEAT_MODE_OFF:
|
||||
mode = Player.REPEAT_MODE_ONE;
|
||||
break;
|
||||
|
@ -547,8 +550,8 @@ public abstract class BasePlayer implements Player.EventListener,
|
|||
break;
|
||||
}
|
||||
|
||||
simpleExoPlayer.setRepeatMode(mode);
|
||||
if (DEBUG) Log.d(TAG, "onRepeatClicked() currentRepeatMode = " + simpleExoPlayer.getRepeatMode());
|
||||
setRepeatMode(mode);
|
||||
if (DEBUG) Log.d(TAG, "onRepeatClicked() currentRepeatMode = " + getRepeatMode());
|
||||
}
|
||||
|
||||
public void onShuffleClicked() {
|
||||
|
@ -982,6 +985,14 @@ public abstract class BasePlayer implements Player.EventListener,
|
|||
return simpleExoPlayer.getPlaybackState() == Player.STATE_READY && simpleExoPlayer.getPlayWhenReady();
|
||||
}
|
||||
|
||||
public int getRepeatMode() {
|
||||
return simpleExoPlayer.getRepeatMode();
|
||||
}
|
||||
|
||||
public void setRepeatMode(final int repeatMode) {
|
||||
simpleExoPlayer.setRepeatMode(repeatMode);
|
||||
}
|
||||
|
||||
public float getPlaybackSpeed() {
|
||||
return getPlaybackParameters().speed;
|
||||
}
|
||||
|
|
|
@ -342,7 +342,7 @@ public final class MainVideoPlayer extends Activity {
|
|||
context,
|
||||
PopupVideoPlayer.class,
|
||||
this.getPlayQueue(),
|
||||
this.simpleExoPlayer.getRepeatMode(),
|
||||
this.getRepeatMode(),
|
||||
this.getPlaybackSpeed(),
|
||||
this.getPlaybackPitch(),
|
||||
this.getPlaybackQuality()
|
||||
|
@ -580,7 +580,7 @@ public final class MainVideoPlayer extends Activity {
|
|||
if (repeatButton == null || shuffleButton == null ||
|
||||
simpleExoPlayer == null || playQueue == null) return;
|
||||
|
||||
setRepeatModeButton(repeatButton, simpleExoPlayer.getRepeatMode());
|
||||
setRepeatModeButton(repeatButton, getRepeatMode());
|
||||
setShuffleButton(shuffleButton, playQueue.isShuffled());
|
||||
}
|
||||
|
||||
|
|
|
@ -277,7 +277,7 @@ public final class PopupVideoPlayer extends Service {
|
|||
notRemoteView.setOnClickPendingIntent(R.id.notificationRepeat,
|
||||
PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_REPEAT), PendingIntent.FLAG_UPDATE_CURRENT));
|
||||
|
||||
setRepeatModeRemote(notRemoteView, playerImpl.simpleExoPlayer.getRepeatMode());
|
||||
setRepeatModeRemote(notRemoteView, playerImpl.getRepeatMode());
|
||||
|
||||
return new NotificationCompat.Builder(this, getString(R.string.notification_channel_id))
|
||||
.setOngoing(true)
|
||||
|
@ -379,6 +379,8 @@ public final class PopupVideoPlayer extends Service {
|
|||
}
|
||||
|
||||
protected void setRepeatModeRemote(final RemoteViews remoteViews, final int repeatMode) {
|
||||
if (remoteViews == null) return;
|
||||
|
||||
switch (repeatMode) {
|
||||
case Player.REPEAT_MODE_OFF:
|
||||
remoteViews.setInt(R.id.notificationRepeat, setImageResourceMethodName, R.drawable.exo_controls_repeat_off);
|
||||
|
@ -439,7 +441,7 @@ public final class PopupVideoPlayer extends Service {
|
|||
context,
|
||||
MainVideoPlayer.class,
|
||||
this.getPlayQueue(),
|
||||
this.simpleExoPlayer.getRepeatMode(),
|
||||
this.getRepeatMode(),
|
||||
this.getPlaybackSpeed(),
|
||||
this.getPlaybackPitch(),
|
||||
this.getPlaybackQuality()
|
||||
|
@ -545,7 +547,7 @@ public final class PopupVideoPlayer extends Service {
|
|||
|
||||
private void updatePlayback() {
|
||||
if (activityListener != null && simpleExoPlayer != null && playQueue != null) {
|
||||
activityListener.onPlaybackUpdate(currentState, simpleExoPlayer.getRepeatMode(), playQueue.isShuffled(), simpleExoPlayer.getPlaybackParameters());
|
||||
activityListener.onPlaybackUpdate(currentState, getRepeatMode(), playQueue.isShuffled(), simpleExoPlayer.getPlaybackParameters());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue