Commit d12c43ff authored by Thomas Guillem's avatar Thomas Guillem
Browse files

VideoPlayer: don't always stop playback on Pause

When receiving a telephone call, onPause/onResume is called but the activity is
not finishing.  This fix avoid to reload the video when the activity lose the
focus.
parent b4f996f1
......@@ -281,6 +281,9 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
private boolean mLostFocus = false;
private boolean mHasAudioFocus = false;
/* Flag to indicate if AudioService is bound or binding */
private boolean mBound = false;
// Tips
private View mOverlayTips;
private static final String PREF_TIPS_SHOWN = "video_player_tips_shown";
......@@ -512,8 +515,9 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
protected void onPause() {
super.onPause();
stopPlayback();
/* Stop the earliest possible to avoid vout error */
if (isFinishing())
stopPlayback();
}
@Override
......@@ -528,6 +532,8 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
protected void onStop() {
super.onStop();
stopPlayback();
// Dismiss the presentation when the activity is not visible.
if (mPresentation != null) {
Log.i(TAG, "Dismissing presentation because the activity is no longer visible.");
......@@ -558,11 +564,10 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
mAudioManager = null;
}
@Override
protected void onResume() {
super.onResume();
mSwitchingView = false;
mPauseOnLoaded = false;
private void bindAudioService() {
if (mBound)
return;
mBound = true;
AudioServiceController.getInstance().bindAudioService(this,
new AudioServiceController.AudioServiceConnectionListener() {
@Override
......@@ -572,9 +577,23 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
@Override
public void onConnectionFailed() {
mBound = false;
mHandler.sendEmptyMessage(AUDIO_SERVICE_CONNECTION_FAILED);
}
});
}
private void unbindAudioService() {
AudioServiceController.getInstance().unbindAudioService(this);
mBound = false;
}
@Override
protected void onResume() {
super.onResume();
mSwitchingView = false;
mPauseOnLoaded = false;
bindAudioService();
if (mIsLocked && mScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR)
setRequestedOrientation(mScreenOrientationLock);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment