[Android] AudioService: don't crash if there is no loaded media

Ludovic Fauvet git at videolan.org
Wed Jul 4 13:36:08 CEST 2012


android | branch: master | Ludovic Fauvet <etix at videolan.org> | Wed Jul  4 13:01:37 2012 +0200| [adc66436425ad8d389338a29ef5db7b2343c41eb] | committer: Ludovic Fauvet

AudioService: don't crash if there is no loaded media

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

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

diff --git a/vlc-android/src/org/videolan/vlc/AudioService.java b/vlc-android/src/org/videolan/vlc/AudioService.java
index a1f4226..4c31168 100644
--- a/vlc-android/src/org/videolan/vlc/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/AudioService.java
@@ -344,10 +344,12 @@ public class AudioService extends Service {
     }
 
     private void play() {
-        mLibVLC.play();
-        mHandler.sendEmptyMessage(SHOW_PROGRESS);
-        showNotification();
-        updateWidget(this);
+        if (mCurrentMedia != null) {
+            mLibVLC.play();
+            mHandler.sendEmptyMessage(SHOW_PROGRESS);
+            showNotification();
+            updateWidget(this);
+        }
     }
 
     private void stop() {
@@ -610,9 +612,10 @@ public class AudioService extends Service {
                 mCurrentMedia = mMediaList.get(position);
             }
 
-            if (mCurrentMedia != null)
+            if (mCurrentMedia != null) {
                 mLibVLC.readMedia(mCurrentMedia.getLocation(), true);
-            showNotification();
+                showNotification();
+            }
         }
 
         @Override



More information about the Android mailing list