-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,
|
remoteViews.setOnClickPendingIntent(R.id.notificationFForward,
|
||||||
PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_FAST_FORWARD), PendingIntent.FLAG_UPDATE_CURRENT));
|
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() {
|
private void updatePlayback() {
|
||||||
if (activityListener != null && simpleExoPlayer != null && playQueue != null) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPlaybackSpeed(intent.getFloatExtra(PLAYBACK_SPEED, getPlaybackSpeed()));
|
final int repeatMode = intent.getIntExtra(REPEAT_MODE, getRepeatMode());
|
||||||
setPlaybackPitch(intent.getFloatExtra(PLAYBACK_PITCH, getPlaybackPitch()));
|
final float playbackSpeed = intent.getFloatExtra(PLAYBACK_SPEED, getPlaybackSpeed());
|
||||||
|
final float playbackPitch = intent.getFloatExtra(PLAYBACK_PITCH, getPlaybackPitch());
|
||||||
|
|
||||||
// Re-initialization
|
// Re-initialization
|
||||||
destroyPlayer();
|
destroyPlayer();
|
||||||
if (playQueue != null) playQueue.dispose();
|
if (playQueue != null) playQueue.dispose();
|
||||||
if (playbackManager != null) playbackManager.dispose();
|
if (playbackManager != null) playbackManager.dispose();
|
||||||
initPlayer();
|
initPlayer();
|
||||||
|
setRepeatMode(repeatMode);
|
||||||
|
setPlaybackParameters(playbackSpeed, playbackPitch);
|
||||||
|
|
||||||
// Good to go...
|
// Good to go...
|
||||||
initPlayback(this, queue);
|
initPlayback(this, queue);
|
||||||
|
@ -534,7 +537,7 @@ public abstract class BasePlayer implements Player.EventListener,
|
||||||
|
|
||||||
final int mode;
|
final int mode;
|
||||||
|
|
||||||
switch (simpleExoPlayer.getRepeatMode()) {
|
switch (getRepeatMode()) {
|
||||||
case Player.REPEAT_MODE_OFF:
|
case Player.REPEAT_MODE_OFF:
|
||||||
mode = Player.REPEAT_MODE_ONE;
|
mode = Player.REPEAT_MODE_ONE;
|
||||||
break;
|
break;
|
||||||
|
@ -547,8 +550,8 @@ public abstract class BasePlayer implements Player.EventListener,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
simpleExoPlayer.setRepeatMode(mode);
|
setRepeatMode(mode);
|
||||||
if (DEBUG) Log.d(TAG, "onRepeatClicked() currentRepeatMode = " + simpleExoPlayer.getRepeatMode());
|
if (DEBUG) Log.d(TAG, "onRepeatClicked() currentRepeatMode = " + getRepeatMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onShuffleClicked() {
|
public void onShuffleClicked() {
|
||||||
|
@ -982,6 +985,14 @@ public abstract class BasePlayer implements Player.EventListener,
|
||||||
return simpleExoPlayer.getPlaybackState() == Player.STATE_READY && simpleExoPlayer.getPlayWhenReady();
|
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() {
|
public float getPlaybackSpeed() {
|
||||||
return getPlaybackParameters().speed;
|
return getPlaybackParameters().speed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -342,7 +342,7 @@ public final class MainVideoPlayer extends Activity {
|
||||||
context,
|
context,
|
||||||
PopupVideoPlayer.class,
|
PopupVideoPlayer.class,
|
||||||
this.getPlayQueue(),
|
this.getPlayQueue(),
|
||||||
this.simpleExoPlayer.getRepeatMode(),
|
this.getRepeatMode(),
|
||||||
this.getPlaybackSpeed(),
|
this.getPlaybackSpeed(),
|
||||||
this.getPlaybackPitch(),
|
this.getPlaybackPitch(),
|
||||||
this.getPlaybackQuality()
|
this.getPlaybackQuality()
|
||||||
|
@ -580,7 +580,7 @@ public final class MainVideoPlayer extends Activity {
|
||||||
if (repeatButton == null || shuffleButton == null ||
|
if (repeatButton == null || shuffleButton == null ||
|
||||||
simpleExoPlayer == null || playQueue == null) return;
|
simpleExoPlayer == null || playQueue == null) return;
|
||||||
|
|
||||||
setRepeatModeButton(repeatButton, simpleExoPlayer.getRepeatMode());
|
setRepeatModeButton(repeatButton, getRepeatMode());
|
||||||
setShuffleButton(shuffleButton, playQueue.isShuffled());
|
setShuffleButton(shuffleButton, playQueue.isShuffled());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -277,7 +277,7 @@ public final class PopupVideoPlayer extends Service {
|
||||||
notRemoteView.setOnClickPendingIntent(R.id.notificationRepeat,
|
notRemoteView.setOnClickPendingIntent(R.id.notificationRepeat,
|
||||||
PendingIntent.getBroadcast(this, NOTIFICATION_ID, new Intent(ACTION_REPEAT), PendingIntent.FLAG_UPDATE_CURRENT));
|
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))
|
return new NotificationCompat.Builder(this, getString(R.string.notification_channel_id))
|
||||||
.setOngoing(true)
|
.setOngoing(true)
|
||||||
|
@ -379,6 +379,8 @@ public final class PopupVideoPlayer extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setRepeatModeRemote(final RemoteViews remoteViews, final int repeatMode) {
|
protected void setRepeatModeRemote(final RemoteViews remoteViews, final int repeatMode) {
|
||||||
|
if (remoteViews == null) return;
|
||||||
|
|
||||||
switch (repeatMode) {
|
switch (repeatMode) {
|
||||||
case Player.REPEAT_MODE_OFF:
|
case Player.REPEAT_MODE_OFF:
|
||||||
remoteViews.setInt(R.id.notificationRepeat, setImageResourceMethodName, R.drawable.exo_controls_repeat_off);
|
remoteViews.setInt(R.id.notificationRepeat, setImageResourceMethodName, R.drawable.exo_controls_repeat_off);
|
||||||
|
@ -439,7 +441,7 @@ public final class PopupVideoPlayer extends Service {
|
||||||
context,
|
context,
|
||||||
MainVideoPlayer.class,
|
MainVideoPlayer.class,
|
||||||
this.getPlayQueue(),
|
this.getPlayQueue(),
|
||||||
this.simpleExoPlayer.getRepeatMode(),
|
this.getRepeatMode(),
|
||||||
this.getPlaybackSpeed(),
|
this.getPlaybackSpeed(),
|
||||||
this.getPlaybackPitch(),
|
this.getPlaybackPitch(),
|
||||||
this.getPlaybackQuality()
|
this.getPlaybackQuality()
|
||||||
|
@ -545,7 +547,7 @@ public final class PopupVideoPlayer extends Service {
|
||||||
|
|
||||||
private void updatePlayback() {
|
private void updatePlayback() {
|
||||||
if (activityListener != null && simpleExoPlayer != null && playQueue != null) {
|
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