[Android] Do not stop PlaybackService on audiofocus loss

Geoffrey Métais git at videolan.org
Fri Feb 26 18:05:21 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Feb 26 18:03:06 2016 +0100| [22a4e01bf3d6380d9c21a56d0f90f9bc11036461] | committer: Geoffrey Métais

Do not stop PlaybackService on audiofocus loss

> https://code.videolan.org/videolan/vlc-android/commit/22a4e01bf3d6380d9c21a56d0f90f9bc11036461
---

 vlc-android/src/org/videolan/vlc/PlaybackService.java | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 9e59b29..a472423 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -359,9 +359,9 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
                 switch (focusChange) {
                     case AudioManager.AUDIOFOCUS_LOSS:
                         Log.i(TAG, "AUDIOFOCUS_LOSS");
-                        // Stop playback
+                        // Pause playback
                         changeAudioFocus(false);
-                        stop();
+                        pause();
                         break;
                     case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
                         Log.i(TAG, "AUDIOFOCUS_LOSS_TRANSIENT");
@@ -397,7 +397,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
     }
 
     @TargetApi(Build.VERSION_CODES.FROYO)
-    private void changeAudioFocusFroyoOrLater(boolean acquire) {
+    private void changeAudioFocus(boolean acquire) {
         final AudioManager am = (AudioManager)getSystemService(AUDIO_SERVICE);
         if (am == null)
             return;
@@ -420,11 +420,6 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
         }
     }
 
-    private void changeAudioFocus(boolean acquire) {
-        if (AndroidUtil.isFroyoOrLater())
-            changeAudioFocusFroyoOrLater(acquire);
-    }
-
 
     @TargetApi(Build.VERSION_CODES.LOLLIPOP)
     private void registerV21() {



More information about the Android mailing list