[Android] Fix AudioPlayer crash on plailist end

Geoffrey Métais git at videolan.org
Thu Jan 14 11:17:48 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jan 14 11:10:20 2016 +0100| [c30e72336fd3d080673e300320ca3f5ad0b79c9d] | committer: Geoffrey Métais

Fix AudioPlayer crash on plailist end

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

 .../src/org/videolan/vlc/gui/audio/AudioPlayer.java       | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
index 975e40c..4dd06d2 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
@@ -360,12 +360,15 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
 
         if (playlistDiffer())
             updateList();
-        mPlaylist.post(new Runnable() {
-            @Override
-            public void run() {
-                mPlaylistAdapter.setCurrentIndex(mService.getCurrentMediaPosition());
-            }
-        });
+        final int position = mService.getCurrentMediaPosition();
+        if (position != -1) {
+            mPlaylist.post(new Runnable() {
+                @Override
+                public void run() {
+                    mPlaylistAdapter.setCurrentIndex(position);
+                }
+            });
+        }
     }
 
     private boolean playlistDiffer() {



More information about the Android mailing list