Close video player when switching to audio
This commit is contained in:
parent
a29041cd4d
commit
a836745079
|
@ -1,7 +1,6 @@
|
|||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Intent;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
|
@ -174,7 +173,6 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
|
|||
super.onPause();
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
||||
@Override
|
||||
public void onTrimMemory(int level) {
|
||||
super.onTrimMemory(level);
|
||||
|
@ -189,16 +187,6 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
|
|||
|
||||
private PlaybackController newPlaybackController() {
|
||||
return new PlaybackController(this) {
|
||||
@Override
|
||||
public void onPositionObserverUpdate() {
|
||||
VideoplayerActivity.this.onPositionObserverUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReloadNotification(int code) {
|
||||
VideoplayerActivity.this.onReloadNotification(code);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updatePlayButtonShowsPlay(boolean showPlay) {
|
||||
viewBinding.playButton.setIsShowPlay(showPlay);
|
||||
|
@ -259,6 +247,13 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
|
|||
if (controller == null || controller.getMedia() == null) {
|
||||
return;
|
||||
}
|
||||
if (controller.getStatus() == PlayerStatus.PLAYING && !controller.isPlayingVideoLocally()) {
|
||||
Log.d(TAG, "Closing, no longer video");
|
||||
destroyingDueToReload = true;
|
||||
finish();
|
||||
new MainActivityStarter(this).withOpenPlayer().start();
|
||||
return;
|
||||
}
|
||||
showTimeLeft = UserPreferences.shouldShowRemainingTime();
|
||||
onPositionObserverUpdate();
|
||||
checkFavorite();
|
||||
|
@ -485,22 +480,6 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
|
|||
}
|
||||
};
|
||||
|
||||
protected void onReloadNotification(int notificationCode) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && PictureInPictureUtil.isInPictureInPictureMode(this)) {
|
||||
if (notificationCode == PlaybackService.EXTRA_CODE_AUDIO
|
||||
|| notificationCode == PlaybackService.EXTRA_CODE_CAST) {
|
||||
finish();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (notificationCode == PlaybackService.EXTRA_CODE_CAST) {
|
||||
Log.d(TAG, "ReloadNotification received, switching to Castplayer now");
|
||||
destroyingDueToReload = true;
|
||||
finish();
|
||||
new MainActivityStarter(this).withOpenPlayer().start();
|
||||
}
|
||||
}
|
||||
|
||||
private void showVideoControls() {
|
||||
viewBinding.bottomControlsContainer.setVisibility(View.VISIBLE);
|
||||
viewBinding.controlsContainer.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -88,11 +88,6 @@ public class ChaptersFragment extends AppCompatDialogFragment {
|
|||
public void loadMediaInfo() {
|
||||
ChaptersFragment.this.loadMediaInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPositionObserverUpdate() {
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
controller.init();
|
||||
EventBus.getDefault().register(this);
|
||||
|
|
|
@ -216,8 +216,6 @@ public abstract class PlaybackController {
|
|||
}
|
||||
mediaInfoLoaded = false;
|
||||
queryService();
|
||||
onReloadNotification(intent.getIntExtra(
|
||||
PlaybackService.EXTRA_NOTIFICATION_CODE, -1));
|
||||
break;
|
||||
case PlaybackService.NOTIFICATION_TYPE_PLAYBACK_END:
|
||||
onPlaybackEnd();
|
||||
|
@ -227,13 +225,6 @@ public abstract class PlaybackController {
|
|||
|
||||
};
|
||||
|
||||
public void onPositionObserverUpdate() {}
|
||||
|
||||
/**
|
||||
* Called when the currently displayed information should be refreshed.
|
||||
*/
|
||||
public void onReloadNotification(int code) {}
|
||||
|
||||
public void onPlaybackEnd() {}
|
||||
|
||||
/**
|
||||
|
@ -245,7 +236,6 @@ public abstract class PlaybackController {
|
|||
checkMediaInfoLoaded();
|
||||
switch (status) {
|
||||
case PAUSED:
|
||||
onPositionObserverUpdate();
|
||||
updatePlayButtonShowsPlay(true);
|
||||
if (!PlaybackService.isCasting() && PlaybackService.getCurrentMediaType() == MediaType.VIDEO) {
|
||||
setScreenOn(false);
|
||||
|
@ -264,14 +254,8 @@ public abstract class PlaybackController {
|
|||
}
|
||||
break;
|
||||
case PREPARED:
|
||||
updatePlayButtonShowsPlay(true);
|
||||
onPositionObserverUpdate();
|
||||
break;
|
||||
case SEEKING:
|
||||
onPositionObserverUpdate();
|
||||
break;
|
||||
case STOPPED: // Fall-through
|
||||
case INITIALIZED:
|
||||
case INITIALIZED: // Fall-through
|
||||
updatePlayButtonShowsPlay(true);
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue