diff --git a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayerActivity.java index 1b5b5d07c..59f6e1e6d 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayerActivity.java @@ -55,7 +55,13 @@ public final class BackgroundPlayerActivity extends ServicePlayerActivity { return true; } - return switchTo(PopupVideoPlayer.class); + this.player.setRecovery(); + getApplicationContext().sendBroadcast(getPlayerShutdownIntent()); + getApplicationContext().startService( + getSwitchIntent(PopupVideoPlayer.class) + .putExtra(BasePlayer.START_PAUSED, !this.player.isPlaying()) + ); + return true; } return false; } diff --git a/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayerActivity.java index b2af6d9d8..5000d07e2 100644 --- a/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayerActivity.java @@ -48,7 +48,13 @@ public final class PopupVideoPlayerActivity extends ServicePlayerActivity { @Override public boolean onPlayerOptionSelected(MenuItem item) { if (item.getItemId() == R.id.action_switch_background) { - return switchTo(BackgroundPlayer.class); + this.player.setRecovery(); + getApplicationContext().sendBroadcast(getPlayerShutdownIntent()); + getApplicationContext().startService( + getSwitchIntent(BackgroundPlayer.class) + .putExtra(BasePlayer.START_PAUSED, !this.player.isPlaying()) + ); + return true; } return false; } diff --git a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java index aeba763be..7aa2be05d 100644 --- a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java @@ -166,7 +166,13 @@ public abstract class ServicePlayerActivity extends AppCompatActivity startActivity(new Intent(Settings.ACTION_SOUND_SETTINGS)); return true; case R.id.action_switch_main: - return switchTo(MainVideoPlayer.class); + this.player.setRecovery(); + getApplicationContext().sendBroadcast(getPlayerShutdownIntent()); + getApplicationContext().startActivity( + getSwitchIntent(MainVideoPlayer.class) + .putExtra(BasePlayer.START_PAUSED, !this.player.isPlaying()) + ); + return true; } return onPlayerOptionSelected(item) || super.onOptionsItemSelected(item); } @@ -190,14 +196,7 @@ public abstract class ServicePlayerActivity extends AppCompatActivity false, false ).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - .putExtra(BasePlayer.START_PAUSED, !this.player.isPlaying()); - } - - protected boolean switchTo(final Class clazz) { - this.player.setRecovery(); - getApplicationContext().sendBroadcast(getPlayerShutdownIntent()); - getApplicationContext().startActivity(getSwitchIntent(clazz)); - return true; + .putExtra(BasePlayer.START_PAUSED, !this.player.isPlaying()); } ////////////////////////////////////////////////////////////////////////////