Commit 059cb7c9 authored by Alexandre Perraud's avatar Alexandre Perraud Committed by Jean-Baptiste Kempf

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

  Close #7542
parent d892b71a
......@@ -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);
......
......@@ -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>
......
......@@ -141,6 +141,9 @@
<string name="plus" translatable="false">+</string>
<string name="minus" translatable="false">&#8722;</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>
......
......@@ -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;
......
......@@ -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 */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment