Commit e31ed462 authored by Filippo Carone's avatar Filippo Carone

jvlc: errorOccurred callback added

parent d320db7e
...@@ -41,7 +41,7 @@ public class MediaPlayerCallback implements LibVlcCallback ...@@ -41,7 +41,7 @@ public class MediaPlayerCallback implements LibVlcCallback
{ {
private MediaPlayerListener listener; private MediaPlayerListener listener;
private MediaPlayer mediaInstance; private MediaPlayer mediaPlayer;
/** /**
* Logger. * Logger.
...@@ -50,7 +50,7 @@ public class MediaPlayerCallback implements LibVlcCallback ...@@ -50,7 +50,7 @@ public class MediaPlayerCallback implements LibVlcCallback
public MediaPlayerCallback(MediaPlayer mediaInstance, MediaPlayerListener listener) public MediaPlayerCallback(MediaPlayer mediaInstance, MediaPlayerListener listener)
{ {
this.mediaInstance = mediaInstance; this.mediaPlayer = mediaInstance;
this.listener = listener; this.listener = listener;
} }
/** /**
...@@ -60,30 +60,35 @@ public class MediaPlayerCallback implements LibVlcCallback ...@@ -60,30 +60,35 @@ public class MediaPlayerCallback implements LibVlcCallback
{ {
if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerPlaying.ordinal()) if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerPlaying.ordinal())
{ {
listener.playing(mediaInstance); listener.playing(mediaPlayer);
} }
else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerPaused.ordinal()) else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerPaused.ordinal())
{ {
listener.paused(mediaInstance); listener.paused(mediaPlayer);
} }
else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerEndReached.ordinal()) else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerEndReached.ordinal())
{ {
listener.endReached(mediaInstance); listener.endReached(mediaPlayer);
} }
else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerPositionChanged.ordinal()) else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerPositionChanged.ordinal())
{ {
listener.positionChanged(mediaInstance); listener.positionChanged(mediaPlayer);
} }
else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerStopped.ordinal()) else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerStopped.ordinal())
{ {
listener.stopped(mediaInstance); listener.stopped(mediaPlayer);
} }
else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerTimeChanged.ordinal()) else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerTimeChanged.ordinal())
{ {
libvlc_event.event_type_specific.setType(LibVlc.media_player_time_changed.class); libvlc_event.event_type_specific.setType(LibVlc.media_player_time_changed.class);
LibVlc.media_player_time_changed timeChanged = (media_player_time_changed) libvlc_event.event_type_specific LibVlc.media_player_time_changed timeChanged = (media_player_time_changed) libvlc_event.event_type_specific
.readField("media_player_time_changed"); .readField("media_player_time_changed");
listener.timeChanged(mediaInstance, timeChanged.new_time); listener.timeChanged(mediaPlayer, timeChanged.new_time);
}
else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerEncounteredError.ordinal())
{
log.warn("Media player encountered error.");
listener.errorOccurred(mediaPlayer);
} }
else else
{ {
......
...@@ -43,4 +43,6 @@ public interface MediaPlayerListener ...@@ -43,4 +43,6 @@ public interface MediaPlayerListener
void positionChanged(MediaPlayer mediaPlayer); void positionChanged(MediaPlayer mediaPlayer);
void errorOccurred(MediaPlayer mediaPlayer);
} }
...@@ -64,6 +64,11 @@ public class VLCExample ...@@ -64,6 +64,11 @@ public class VLCExample
{ {
System.out.println("Media player stopped. MRL: " + mediaPlayer.getMediaDescriptor().getMrl()); System.out.println("Media player stopped. MRL: " + mediaPlayer.getMediaDescriptor().getMrl());
} }
public void errorOccurred(MediaPlayer mediaPlayer)
{
System.out.println("An error has occurred.");
}
}); });
mediaPlayer.play(); mediaPlayer.play();
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* Created on 28-feb-2006 * Created on 28-feb-2006
* *
* $Id: AudioIntf.java 8 2006-02-28 12:03:47Z little $ * $Id: $
* *
* This program is free software; you can redistribute it * This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public License * and/or modify it under the terms of the GNU General Public License
......
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