[Android] Video player : Warn user if a deleted media is played.

Alexandre Perraud git at videolan.org
Mon Mar 18 18:39:23 CET 2013


vlc-ports/android | branch: master | Alexandre Perraud <4leyx4ndre at gmail.com> | Mon Mar 18 18:23:46 2013 +0100| [059cb7c9d509d715dbe81b0b3aa274dec37374c6] | committer: Jean-Baptiste Kempf

Video player : Warn user if a deleted media is played.

  Close #7542

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

 vlc-android/jni/libvlcjni.c                        |    3 ++-
 vlc-android/res/values-fr/strings.xml              |    2 ++
 vlc-android/res/values/strings.xml                 |    3 +++
 vlc-android/src/org/videolan/vlc/EventManager.java |    2 +-
 .../vlc/gui/video/VideoPlayerActivity.java         |   20 ++++++++++++++++++++
 5 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/vlc-android/jni/libvlcjni.c b/vlc-android/jni/libvlcjni.c
index 6858f09..429bc10 100644
--- a/vlc-android/jni/libvlcjni.c
+++ b/vlc-android/jni/libvlcjni.c
@@ -687,7 +687,8 @@ static void create_player_and_play(JNIEnv* env, jobject thiz,
         libvlc_MediaPlayerEndReached,
         libvlc_MediaPlayerStopped,
         libvlc_MediaPlayerVout,
-        libvlc_MediaPlayerPositionChanged
+        libvlc_MediaPlayerPositionChanged,
+        libvlc_MediaPlayerEncounteredError
     };
     for(int i = 0; i < (sizeof(mp_events) / sizeof(*mp_events)); i++)
         libvlc_event_attach(ev, mp_events[i], vlc_event_callback, myVm);
diff --git a/vlc-android/res/values-fr/strings.xml b/vlc-android/res/values-fr/strings.xml
index 83ee535..2eaa3f5 100644
--- a/vlc-android/res/values-fr/strings.xml
+++ b/vlc-android/res/values-fr/strings.xml
@@ -119,6 +119,8 @@
     <string name="error_problem">Désolé, VLC pour Android à rencontré un problème et a dû s\'arrêter.</string>
     <string name="error_message_is">Le message d\'erreur est le suivant (merci de le mentionner):\n</string>
 
+    <string name="encountered_error_title">Erreur de lecture</string>
+    <string name="encountered_error_message">Une erreur est survenue à la lecture de ce média.\nVous devriez peut-être rafraîchir votre bibliothèque multimédia.</string>
 
     <!-- About -->
     <string name="app_name_full">Lecteur multimédia VLC</string>
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index 40a8ef2..8277dd4 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -141,6 +141,9 @@
     <string name="plus" translatable="false">+</string>
     <string name="minus" translatable="false">−</string>
 
+    <string name="encountered_error_title">Playback error</string>
+    <string name="encountered_error_message">VLC has encountered a error with this media.\nYou should maybe refresh your media library</string>
+
     <!-- About -->
     <string name="app_name_full">VLC for Android™</string>
     <string name="licence">License</string>
diff --git a/vlc-android/src/org/videolan/vlc/EventManager.java b/vlc-android/src/org/videolan/vlc/EventManager.java
index 2d5ec80..8075de3 100644
--- a/vlc-android/src/org/videolan/vlc/EventManager.java
+++ b/vlc-android/src/org/videolan/vlc/EventManager.java
@@ -49,7 +49,7 @@ public class EventManager {
     //public static final int MediaPlayerForward              = 0x107;
     //public static final int MediaPlayerBackward             = 0x108;
     public static final int MediaPlayerEndReached             = 0x109;
-    //public static final int MediaPlayerEncounteredError     = 0x10a;
+    public static final int MediaPlayerEncounteredError       = 0x10a;
     //public static final int MediaPlayerTimeChanged          = 0x10b;
     public static final int MediaPlayerPositionChanged        = 0x10c;
     //public static final int MediaPlayerSeekableChanged      = 0x10d;
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 1191465..dcfbd0c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -86,6 +86,7 @@ import android.view.animation.AnimationUtils;
 import android.widget.FrameLayout;
 import android.widget.ImageButton;
 import android.widget.SeekBar;
+import android.widget.Toast;
 import android.widget.SeekBar.OnSeekBarChangeListener;
 import android.widget.TextView;
 
@@ -622,6 +623,10 @@ public class VideoPlayerActivity extends Activity {
                 case EventManager.MediaPlayerPositionChanged:
                     //don't spam the logs
                     break;
+                case EventManager.MediaPlayerEncounteredError:
+                    Log.i(TAG, "MediaPlayerEncounteredError");
+                    activity.encounteredError();
+                    break;
                 default:
                     Log.e(TAG, String.format("Event not handled (0x%x)", msg.getData().getInt("event")));
                     break;
@@ -677,6 +682,21 @@ public class VideoPlayerActivity extends Activity {
         finish();
     }
 
+    private void encounteredError() {
+        /* Encountered Error, exit player with a message */
+        AlertDialog dialog = new AlertDialog.Builder(VideoPlayerActivity.this)
+        .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialog, int id) {
+                finish();
+            }
+        })
+        .setTitle(R.string.encountered_error_title)
+        .setMessage(R.string.encountered_error_message)
+        .create();
+        dialog.show();
+    }
+
     private void handleVout(Message msg) {
         if (msg.getData().getInt("data") == 0 && !mEndReached) {
             /* Video track lost, open in audio mode */



More information about the Android mailing list