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
{
private MediaPlayerListener listener;
private MediaPlayer mediaInstance;
private MediaPlayer mediaPlayer;
/**
* Logger.
......@@ -50,7 +50,7 @@ public class MediaPlayerCallback implements LibVlcCallback
public MediaPlayerCallback(MediaPlayer mediaInstance, MediaPlayerListener listener)
{
this.mediaInstance = mediaInstance;
this.mediaPlayer = mediaInstance;
this.listener = listener;
}
/**
......@@ -60,30 +60,35 @@ public class MediaPlayerCallback implements LibVlcCallback
{
if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerPlaying.ordinal())
{
listener.playing(mediaInstance);
listener.playing(mediaPlayer);
}
else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerPaused.ordinal())
{
listener.paused(mediaInstance);
listener.paused(mediaPlayer);
}
else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerEndReached.ordinal())
{
listener.endReached(mediaInstance);
listener.endReached(mediaPlayer);
}
else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerPositionChanged.ordinal())
{
listener.positionChanged(mediaInstance);
listener.positionChanged(mediaPlayer);
}
else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerStopped.ordinal())
{
listener.stopped(mediaInstance);
listener.stopped(mediaPlayer);
}
else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerTimeChanged.ordinal())
{
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
.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
{
......
......@@ -43,4 +43,6 @@ public interface MediaPlayerListener
void positionChanged(MediaPlayer mediaPlayer);
void errorOccurred(MediaPlayer mediaPlayer);
}
......@@ -64,6 +64,11 @@ public class VLCExample
{
System.out.println("Media player stopped. MRL: " + mediaPlayer.getMediaDescriptor().getMrl());
}
public void errorOccurred(MediaPlayer mediaPlayer)
{
System.out.println("An error has occurred.");
}
});
mediaPlayer.play();
......
......@@ -5,7 +5,7 @@
*
* 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
* 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