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
|
||||
protected void onStop() {
|
||||
stopPlaybackIfUserPreferencesSpecified(); // MUST be called before super.onStop(), while it still has member variable controller
|
||||
super.onStop();
|
||||
if (!PictureInPictureUtil.isInPictureInPictureMode(this)) {
|
||||
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
|
||||
public void onUserLeaveHint () {
|
||||
if (!PictureInPictureUtil.isInPictureInPictureMode(this) && UserPreferences.getVideoBackgroundBehavior()
|
||||
|
@ -275,13 +285,12 @@ public class VideoplayerActivity extends MediaplayerActivity {
|
|||
|
||||
@Override
|
||||
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;
|
||||
if (controller != null && !destroyingDueToReload
|
||||
&& UserPreferences.getVideoBackgroundBehavior()
|
||||
!= UserPreferences.VideoBackgroundBehavior.CONTINUE_PLAYING) {
|
||||
controller.notifyVideoSurfaceAbandoned();
|
||||
}
|
||||
stopPlaybackIfUserPreferencesSpecified();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -605,6 +605,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
}
|
||||
|
||||
public void notifyVideoSurfaceAbandoned() {
|
||||
Log.v(TAG, "notifyVideoSurfaceAbandoned()");
|
||||
mediaPlayer.pause(true, false);
|
||||
mediaPlayer.resetVideoSurface();
|
||||
}
|
||||
|
|
|
@ -764,6 +764,7 @@ public abstract class PlaybackController {
|
|||
}
|
||||
|
||||
public void notifyVideoSurfaceAbandoned() {
|
||||
Log.v(TAG, "notifyVideoSurfaceAbandoned() - hasPlaybackService=" + (playbackService != null));
|
||||
if (playbackService != null) {
|
||||
playbackService.notifyVideoSurfaceAbandoned();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue