[Android] AudioService: fix video stream playback

Edward Wang git at videolan.org
Mon Aug 12 22:26:13 CEST 2013


vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Mon Aug 12 16:23:25 2013 -0400| [e16fa987db85bfec6d0226ad5d9d384ea7c27b65] | committer: Edward Wang

AudioService: fix video stream playback

Fix regression from 02ee423e8b11263f90f11a47bba3ebb46cee3457 where hiding the notification kills the stream.

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=e16fa987db85bfec6d0226ad5d9d384ea7c27b65
---

 vlc-android/src/org/videolan/vlc/AudioService.java |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/AudioService.java b/vlc-android/src/org/videolan/vlc/AudioService.java
index f72d651..ec6c638 100644
--- a/vlc-android/src/org/videolan/vlc/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/AudioService.java
@@ -470,7 +470,8 @@ public class AudioService extends Service {
     private void handleVout() {
         Log.i(TAG, "Obtained video track");
         mMediaList.clear();
-        hideNotification();
+        // Preserve playback when switching to video
+        hideNotification(false);
 
         // Don't crash if user stopped the media
         if(mCurrentMedia == null) return;
@@ -605,8 +606,18 @@ public class AudioService extends Service {
     }
 
     private void hideNotification() {
+        hideNotification(true);
+    }
+
+    /**
+     * Hides the VLC notification and stops the service.
+     *
+     * @param stopPlayback True to also stop playback at the same time. Set to false to preserve playback (e.g. for vout events)
+     */
+    private void hideNotification(boolean stopPlayback) {
         stopForeground(true);
-        stopSelf();
+        if(stopPlayback)
+            stopSelf();
     }
 
     private void pause() {



More information about the Android mailing list