[Android] Fix crash after phone call

Geoffrey Métais git at videolan.org
Wed Feb 14 17:36:26 CET 2018


vlc-android | branch: 3.0.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Feb 13 13:05:10 2018 +0100| [1edbc1cab48f06364bb060bc441862e9b055c57a] | committer: Geoffrey Métais

Fix crash after phone call

(cherry picked from commit 94b38b61eb5434dbab2e7e7bef4d821806e049b1)

> https://code.videolan.org/videolan/vlc-android/commit/1edbc1cab48f06364bb060bc441862e9b055c57a
---

 vlc-android/src/org/videolan/vlc/PlaybackService.java     |  1 -
 vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt | 12 +++++++-----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 7cfd96ed6..350e23cdb 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -287,7 +287,6 @@ public class PlaybackService extends MediaBrowserServiceCompat{
             mRemoteControlClientReceiver = null;
         }
         playlistManager.onServiceDestroyed();
-        updateWidget();
     }
 
     @Override
diff --git a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index 8d391e517..f92137485 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -146,7 +146,9 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
         }
     }
 
-    fun play() = player.play()
+    fun play() {
+        if (hasMedia()) player.play()
+    }
 
     fun pause() {
         if (player.pause()) savePosition()
@@ -179,10 +181,8 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
         currentIndex = -1
         mediaList.clear()
         if (systemExit) player.release()
-        else {
-            player.restart()
-            service.onPlaybackStopped()
-        }
+        else player.restart()
+        service.onPlaybackStopped()
     }
 
     @MainThread
@@ -670,4 +670,6 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
         }
         service.onMediaPlayerEvent(event)
     }
+
+    fun isAudioList() = !player.canSwitchToVideo() && mediaList.isAudioList
 }
\ No newline at end of file



More information about the Android mailing list