[vlc-devel] commit: jvlc: errorOccurred callback added (Filippo Carone )

git version control git at videolan.org
Sun Jul 27 22:22:35 CEST 2008


vlc | branch: master | Filippo Carone <littlejohn at videolan.org> | Sun Jul 27 22:23:14 2008 +0200| [e31ed462208f01beed8886b797884ebb8605f882]

jvlc: errorOccurred callback added

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

 .../videolan/jvlc/event/MediaPlayerCallback.java   |   21 ++++++++++++-------
 .../videolan/jvlc/event/MediaPlayerListener.java   |    2 +
 .../java/org/videolan/jvlc/example/VLCExample.java |    5 ++++
 .../samples/client/src/main/java/VlcClient.java    |    2 +-
 4 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/bindings/java/core/src/main/java/org/videolan/jvlc/event/MediaPlayerCallback.java b/bindings/java/core/src/main/java/org/videolan/jvlc/event/MediaPlayerCallback.java
index 54d67f9..849950c 100644
--- a/bindings/java/core/src/main/java/org/videolan/jvlc/event/MediaPlayerCallback.java
+++ b/bindings/java/core/src/main/java/org/videolan/jvlc/event/MediaPlayerCallback.java
@@ -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
         {
diff --git a/bindings/java/core/src/main/java/org/videolan/jvlc/event/MediaPlayerListener.java b/bindings/java/core/src/main/java/org/videolan/jvlc/event/MediaPlayerListener.java
index 8877522..de95b00 100644
--- a/bindings/java/core/src/main/java/org/videolan/jvlc/event/MediaPlayerListener.java
+++ b/bindings/java/core/src/main/java/org/videolan/jvlc/event/MediaPlayerListener.java
@@ -43,4 +43,6 @@ public interface MediaPlayerListener
     
     void positionChanged(MediaPlayer mediaPlayer);
     
+    void errorOccurred(MediaPlayer mediaPlayer);
+    
 }
diff --git a/bindings/java/core/src/main/java/org/videolan/jvlc/example/VLCExample.java b/bindings/java/core/src/main/java/org/videolan/jvlc/example/VLCExample.java
index 0d51620..1c6f7d2 100644
--- a/bindings/java/core/src/main/java/org/videolan/jvlc/example/VLCExample.java
+++ b/bindings/java/core/src/main/java/org/videolan/jvlc/example/VLCExample.java
@@ -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();
 
diff --git a/bindings/java/samples/client/src/main/java/VlcClient.java b/bindings/java/samples/client/src/main/java/VlcClient.java
index a1b6692..c44fea8 100644
--- a/bindings/java/samples/client/src/main/java/VlcClient.java
+++ b/bindings/java/samples/client/src/main/java/VlcClient.java
@@ -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




More information about the vlc-devel mailing list