[Android] Stop popup playback when needed

Geoffrey Métais git at videolan.org
Fri Apr 1 12:04:02 CEST 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Mar 30 16:45:56 2016 +0200| [5d7cd3756a50e4c3d3382c41f0105873522c9ff9] | committer: Geoffrey Métais

Stop popup playback when needed

> https://code.videolan.org/videolan/vlc-android/commit/5d7cd3756a50e4c3d3382c41f0105873522c9ff9
---

 vlc-android/src/org/videolan/vlc/PlaybackService.java               | 6 +++++-
 vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index aeb173d..587fc86 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -960,7 +960,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
     }
 
     @MainThread
-    public void stop() {
+    public void stopPlayback() {
         if (mMediaSession != null) {
             mMediaSession.setActive(false);
             mMediaSession.release();
@@ -987,7 +987,11 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
         executeUpdate();
         executeUpdateProgress();
         changeAudioFocus(false);
+    }
 
+    @MainThread
+    public void stop() {
+        stopPlayback();
         stopSelf();
     }
 
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 0ce9696..fce45ad 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -710,6 +710,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         mPlaybackStarted = true;
 
         final IVLCVout vlcVout = mService.getVLCVout();
+        if (vlcVout.areViewsAttached())
+            mService.stopPlayback();
         if (mPresentation == null) {
             vlcVout.setVideoView(mSurfaceView);
             if (mSubtitlesSurfaceView.getVisibility() != View.GONE)



More information about the Android mailing list