more #2716 - fix VideoPlayback upon hitting home button.
This commit is contained in:
parent
f3980091a9
commit
76fbab8e82
|
@ -91,12 +91,22 @@ public class VideoplayerActivity extends MediaplayerActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
|
stopPlaybackIfUserPreferencesSpecified(); // MUST be called before super.onStop(), while it still has member variable controller
|
||||||
super.onStop();
|
super.onStop();
|
||||||
if (!PictureInPictureUtil.isInPictureInPictureMode(this)) {
|
if (!PictureInPictureUtil.isInPictureInPictureMode(this)) {
|
||||||
videoControlsHider.stop();
|
videoControlsHider.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void stopPlaybackIfUserPreferencesSpecified() {
|
||||||
|
if (controller != null && !destroyingDueToReload
|
||||||
|
&& UserPreferences.getVideoBackgroundBehavior()
|
||||||
|
!= UserPreferences.VideoBackgroundBehavior.CONTINUE_PLAYING) {
|
||||||
|
Log.v(TAG, "stop video playback per UserPreference");
|
||||||
|
controller.notifyVideoSurfaceAbandoned();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUserLeaveHint () {
|
public void onUserLeaveHint () {
|
||||||
if (!PictureInPictureUtil.isInPictureInPictureMode(this) && UserPreferences.getVideoBackgroundBehavior()
|
if (!PictureInPictureUtil.isInPictureInPictureMode(this) && UserPreferences.getVideoBackgroundBehavior()
|
||||||
|
@ -275,13 +285,12 @@ public class VideoplayerActivity extends MediaplayerActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||||
Log.d(TAG, "Videosurface was destroyed");
|
Log.d(TAG, "Videosurface was destroyed." );
|
||||||
|
Log.v(TAG, " hasController=" + (controller != null)
|
||||||
|
+ " , destroyingDueToReload=" + destroyingDueToReload
|
||||||
|
+ " , videoBackgroundBehavior=" + UserPreferences.getVideoBackgroundBehavior());
|
||||||
videoSurfaceCreated = false;
|
videoSurfaceCreated = false;
|
||||||
if (controller != null && !destroyingDueToReload
|
stopPlaybackIfUserPreferencesSpecified();
|
||||||
&& UserPreferences.getVideoBackgroundBehavior()
|
|
||||||
!= UserPreferences.VideoBackgroundBehavior.CONTINUE_PLAYING) {
|
|
||||||
controller.notifyVideoSurfaceAbandoned();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -605,6 +605,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyVideoSurfaceAbandoned() {
|
public void notifyVideoSurfaceAbandoned() {
|
||||||
|
Log.v(TAG, "notifyVideoSurfaceAbandoned()");
|
||||||
mediaPlayer.pause(true, false);
|
mediaPlayer.pause(true, false);
|
||||||
mediaPlayer.resetVideoSurface();
|
mediaPlayer.resetVideoSurface();
|
||||||
}
|
}
|
||||||
|
|
|
@ -764,6 +764,7 @@ public abstract class PlaybackController {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyVideoSurfaceAbandoned() {
|
public void notifyVideoSurfaceAbandoned() {
|
||||||
|
Log.v(TAG, "notifyVideoSurfaceAbandoned() - hasPlaybackService=" + (playbackService != null));
|
||||||
if (playbackService != null) {
|
if (playbackService != null) {
|
||||||
playbackService.notifyVideoSurfaceAbandoned();
|
playbackService.notifyVideoSurfaceAbandoned();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue