No need to have a virtual method that is only used in one single instance
This commit is contained in:
parent
a836745079
commit
1e336ac0f8
|
@ -190,6 +190,16 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
|
|||
@Override
|
||||
protected void updatePlayButtonShowsPlay(boolean showPlay) {
|
||||
viewBinding.playButton.setIsShowPlay(showPlay);
|
||||
if (showPlay) {
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
} else {
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
setupVideoAspectRatio();
|
||||
if (videoSurfaceCreated && controller != null) {
|
||||
Log.d(TAG, "Videosurface already created, setting videosurface now");
|
||||
controller.setVideoSurface(viewBinding.videoView.getHolder());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -197,28 +207,10 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
|
|||
VideoplayerActivity.this.loadMediaInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAwaitingVideoSurface() {
|
||||
setupVideoAspectRatio();
|
||||
if (videoSurfaceCreated && controller != null) {
|
||||
Log.d(TAG, "Videosurface already created, setting videosurface now");
|
||||
controller.setVideoSurface(viewBinding.videoView.getHolder());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlaybackEnd() {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setScreenOn(boolean enable) {
|
||||
if (enable) {
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
} else {
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -235,17 +235,7 @@ public abstract class PlaybackController {
|
|||
Log.d(TAG, "status: " + status.toString());
|
||||
checkMediaInfoLoaded();
|
||||
switch (status) {
|
||||
case PAUSED:
|
||||
updatePlayButtonShowsPlay(true);
|
||||
if (!PlaybackService.isCasting() && PlaybackService.getCurrentMediaType() == MediaType.VIDEO) {
|
||||
setScreenOn(false);
|
||||
}
|
||||
break;
|
||||
case PLAYING:
|
||||
if (!PlaybackService.isCasting() && PlaybackService.getCurrentMediaType() == MediaType.VIDEO) {
|
||||
onAwaitingVideoSurface();
|
||||
setScreenOn(true);
|
||||
}
|
||||
updatePlayButtonShowsPlay(false);
|
||||
break;
|
||||
case PREPARING:
|
||||
|
@ -253,7 +243,8 @@ public abstract class PlaybackController {
|
|||
updatePlayButtonShowsPlay(!playbackService.isStartWhenPrepared());
|
||||
}
|
||||
break;
|
||||
case PREPARED:
|
||||
case PAUSED:
|
||||
case PREPARED: // Fall-through
|
||||
case STOPPED: // Fall-through
|
||||
case INITIALIZED: // Fall-through
|
||||
updatePlayButtonShowsPlay(true);
|
||||
|
@ -277,8 +268,6 @@ public abstract class PlaybackController {
|
|||
|
||||
public abstract void loadMediaInfo();
|
||||
|
||||
public void onAwaitingVideoSurface() {}
|
||||
|
||||
/**
|
||||
* Called when connection to playback service has been established or
|
||||
* information has to be refreshed
|
||||
|
@ -300,16 +289,6 @@ public abstract class PlaybackController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be implemented by classes that show a video. The default implementation
|
||||
* does nothing
|
||||
*
|
||||
* @param enable True if the screen should be kept on, false otherwise
|
||||
*/
|
||||
protected void setScreenOn(boolean enable) {
|
||||
|
||||
}
|
||||
|
||||
public void playPause() {
|
||||
if (playbackService == null) {
|
||||
new PlaybackServiceStarter(activity, media).start();
|
||||
|
|
Loading…
Reference in New Issue