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;
|
package de.danoeh.antennapod.activity;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
@ -174,7 +173,6 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrimMemory(int level) {
|
public void onTrimMemory(int level) {
|
||||||
super.onTrimMemory(level);
|
super.onTrimMemory(level);
|
||||||
|
@ -189,16 +187,6 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
|
||||||
|
|
||||||
private PlaybackController newPlaybackController() {
|
private PlaybackController newPlaybackController() {
|
||||||
return new PlaybackController(this) {
|
return new PlaybackController(this) {
|
||||||
@Override
|
|
||||||
public void onPositionObserverUpdate() {
|
|
||||||
VideoplayerActivity.this.onPositionObserverUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onReloadNotification(int code) {
|
|
||||||
VideoplayerActivity.this.onReloadNotification(code);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updatePlayButtonShowsPlay(boolean showPlay) {
|
protected void updatePlayButtonShowsPlay(boolean showPlay) {
|
||||||
viewBinding.playButton.setIsShowPlay(showPlay);
|
viewBinding.playButton.setIsShowPlay(showPlay);
|
||||||
|
@ -259,6 +247,13 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
|
||||||
if (controller == null || controller.getMedia() == null) {
|
if (controller == null || controller.getMedia() == null) {
|
||||||
return;
|
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();
|
showTimeLeft = UserPreferences.shouldShowRemainingTime();
|
||||||
onPositionObserverUpdate();
|
onPositionObserverUpdate();
|
||||||
checkFavorite();
|
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() {
|
private void showVideoControls() {
|
||||||
viewBinding.bottomControlsContainer.setVisibility(View.VISIBLE);
|
viewBinding.bottomControlsContainer.setVisibility(View.VISIBLE);
|
||||||
viewBinding.controlsContainer.setVisibility(View.VISIBLE);
|
viewBinding.controlsContainer.setVisibility(View.VISIBLE);
|
||||||
|
|
|
@ -88,11 +88,6 @@ public class ChaptersFragment extends AppCompatDialogFragment {
|
||||||
public void loadMediaInfo() {
|
public void loadMediaInfo() {
|
||||||
ChaptersFragment.this.loadMediaInfo();
|
ChaptersFragment.this.loadMediaInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPositionObserverUpdate() {
|
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
controller.init();
|
controller.init();
|
||||||
EventBus.getDefault().register(this);
|
EventBus.getDefault().register(this);
|
||||||
|
|
|
@ -216,8 +216,6 @@ public abstract class PlaybackController {
|
||||||
}
|
}
|
||||||
mediaInfoLoaded = false;
|
mediaInfoLoaded = false;
|
||||||
queryService();
|
queryService();
|
||||||
onReloadNotification(intent.getIntExtra(
|
|
||||||
PlaybackService.EXTRA_NOTIFICATION_CODE, -1));
|
|
||||||
break;
|
break;
|
||||||
case PlaybackService.NOTIFICATION_TYPE_PLAYBACK_END:
|
case PlaybackService.NOTIFICATION_TYPE_PLAYBACK_END:
|
||||||
onPlaybackEnd();
|
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() {}
|
public void onPlaybackEnd() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -245,7 +236,6 @@ public abstract class PlaybackController {
|
||||||
checkMediaInfoLoaded();
|
checkMediaInfoLoaded();
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case PAUSED:
|
case PAUSED:
|
||||||
onPositionObserverUpdate();
|
|
||||||
updatePlayButtonShowsPlay(true);
|
updatePlayButtonShowsPlay(true);
|
||||||
if (!PlaybackService.isCasting() && PlaybackService.getCurrentMediaType() == MediaType.VIDEO) {
|
if (!PlaybackService.isCasting() && PlaybackService.getCurrentMediaType() == MediaType.VIDEO) {
|
||||||
setScreenOn(false);
|
setScreenOn(false);
|
||||||
|
@ -264,14 +254,8 @@ public abstract class PlaybackController {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PREPARED:
|
case PREPARED:
|
||||||
updatePlayButtonShowsPlay(true);
|
|
||||||
onPositionObserverUpdate();
|
|
||||||
break;
|
|
||||||
case SEEKING:
|
|
||||||
onPositionObserverUpdate();
|
|
||||||
break;
|
|
||||||
case STOPPED: // Fall-through
|
case STOPPED: // Fall-through
|
||||||
case INITIALIZED:
|
case INITIALIZED: // Fall-through
|
||||||
updatePlayButtonShowsPlay(true);
|
updatePlayButtonShowsPlay(true);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue