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
|
@Override
|
||||||
protected void updatePlayButtonShowsPlay(boolean showPlay) {
|
protected void updatePlayButtonShowsPlay(boolean showPlay) {
|
||||||
viewBinding.playButton.setIsShowPlay(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
|
@Override
|
||||||
@ -197,28 +207,10 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
|
|||||||
VideoplayerActivity.this.loadMediaInfo();
|
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
|
@Override
|
||||||
public void onPlaybackEnd() {
|
public void onPlaybackEnd() {
|
||||||
finish();
|
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());
|
Log.d(TAG, "status: " + status.toString());
|
||||||
checkMediaInfoLoaded();
|
checkMediaInfoLoaded();
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case PAUSED:
|
|
||||||
updatePlayButtonShowsPlay(true);
|
|
||||||
if (!PlaybackService.isCasting() && PlaybackService.getCurrentMediaType() == MediaType.VIDEO) {
|
|
||||||
setScreenOn(false);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PLAYING:
|
case PLAYING:
|
||||||
if (!PlaybackService.isCasting() && PlaybackService.getCurrentMediaType() == MediaType.VIDEO) {
|
|
||||||
onAwaitingVideoSurface();
|
|
||||||
setScreenOn(true);
|
|
||||||
}
|
|
||||||
updatePlayButtonShowsPlay(false);
|
updatePlayButtonShowsPlay(false);
|
||||||
break;
|
break;
|
||||||
case PREPARING:
|
case PREPARING:
|
||||||
@ -253,7 +243,8 @@ public abstract class PlaybackController {
|
|||||||
updatePlayButtonShowsPlay(!playbackService.isStartWhenPrepared());
|
updatePlayButtonShowsPlay(!playbackService.isStartWhenPrepared());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PREPARED:
|
case PAUSED:
|
||||||
|
case PREPARED: // Fall-through
|
||||||
case STOPPED: // Fall-through
|
case STOPPED: // Fall-through
|
||||||
case INITIALIZED: // Fall-through
|
case INITIALIZED: // Fall-through
|
||||||
updatePlayButtonShowsPlay(true);
|
updatePlayButtonShowsPlay(true);
|
||||||
@ -277,8 +268,6 @@ public abstract class PlaybackController {
|
|||||||
|
|
||||||
public abstract void loadMediaInfo();
|
public abstract void loadMediaInfo();
|
||||||
|
|
||||||
public void onAwaitingVideoSurface() {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when connection to playback service has been established or
|
* Called when connection to playback service has been established or
|
||||||
* information has to be refreshed
|
* 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() {
|
public void playPause() {
|
||||||
if (playbackService == null) {
|
if (playbackService == null) {
|
||||||
new PlaybackServiceStarter(activity, media).start();
|
new PlaybackServiceStarter(activity, media).start();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user