jvlc: MediaPlayerListener stopped method added
authorFilippo Carone <littlejohn@videolan.org>
Mon, 21 Jul 2008 20:21:31 +0000 (22:21 +0200)
committerFilippo Carone <littlejohn@videolan.org>
Mon, 21 Jul 2008 20:23:06 +0000 (22:23 +0200)
bindings/java/core/src/main/java/org/videolan/jvlc/MediaDescriptor.java
bindings/java/core/src/main/java/org/videolan/jvlc/event/MediaPlayerCallback.java
bindings/java/core/src/main/java/org/videolan/jvlc/event/MediaPlayerListener.java
bindings/java/core/src/main/java/org/videolan/jvlc/example/VLCExample.java

index 34e672f..d282963 100644 (file)
@@ -69,7 +69,7 @@ public class MediaDescriptor
         return libvlc.libvlc_media_get_mrl(instance);
     }
     
-    public MediaPlayer getMediaInstance()
+    public MediaPlayer getMediaPlayer()
     {
         return new MediaPlayer(this);
     }
index db878e7..5533c74 100644 (file)
@@ -53,7 +53,7 @@ public class MediaPlayerCallback implements LibVlcCallback
     {
         if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerPlaying.ordinal())
         {
-            listener.played(mediaInstance);
+            listener.playing(mediaInstance);
         }
         else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerPaused.ordinal())
         {
@@ -67,6 +67,10 @@ public class MediaPlayerCallback implements LibVlcCallback
         {
             listener.positionChanged(mediaInstance);
         }
+        else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerStopped.ordinal())
+        {
+            listener.stopped(mediaInstance);
+        }
         else if (libvlc_event.type == LibVlcEventType.libvlc_MediaPlayerTimeChanged.ordinal())
         {
             libvlc_event.event_type_specific.setType(LibVlc.media_player_time_changed.class);
index 5ebaf37..8877522 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * MediaInstancePlayListener.java: VLC Java Bindings
+ * mediaPlayerPlayListener.java: VLC Java Bindings
  *****************************************************************************
  * Copyright (C) 1998-2008 the VideoLAN team
  *
@@ -31,14 +31,16 @@ import org.videolan.jvlc.MediaPlayer;
 public interface MediaPlayerListener
 {
 
-    void played(MediaPlayer mediaInstance);
+    void playing(MediaPlayer mediaPlayer);
     
-    void paused(MediaPlayer mediaInstance);
+    void paused(MediaPlayer mediaPlayer);
     
-    void endReached(MediaPlayer mediaInstance);
+    void stopped(MediaPlayer mediaPlayer);
     
-    void timeChanged(MediaPlayer mediaInstance, long newTime);
+    void endReached(MediaPlayer mediaPlayer);
     
-    void positionChanged(MediaPlayer mediaInstance);
+    void timeChanged(MediaPlayer mediaPlayer, long newTime);
+    
+    void positionChanged(MediaPlayer mediaPlayer);
     
 }
index 41ec321..0d51620 100644 (file)
@@ -30,54 +30,59 @@ public class VLCExample
         System.out.println("... done.");
 
         MediaDescriptor mediaDescriptor = new MediaDescriptor(jvlc, "/home/carone/apps/a.avi");
-        MediaPlayer mediaInstance = mediaDescriptor.getMediaInstance();
+        MediaPlayer mediaPlayer = mediaDescriptor.getMediaPlayer();
 
-        mediaInstance.addListener(new MediaPlayerListener()
+        mediaPlayer.addListener(new MediaPlayerListener()
         {
 
-            public void endReached(MediaPlayer mediaInstance)
+            public void endReached(MediaPlayer mediaPlayer)
             {
-                System.out.println("Media instance end reached. MRL: " + mediaInstance.getMediaDescriptor().getMrl());
+                System.out.println("Media instance end reached. MRL: " + mediaPlayer.getMediaDescriptor().getMrl());
             }
 
-            public void paused(MediaPlayer mediaInstance)
+            public void paused(MediaPlayer mediaPlayer)
             {
-                System.out.println("Media instance paused. MRL: " + mediaInstance.getMediaDescriptor().getMrl());
+                System.out.println("Media instance paused. MRL: " + mediaPlayer.getMediaDescriptor().getMrl());
             }
 
-            public void played(MediaPlayer mediaInstance)
+            public void playing(MediaPlayer mediaPlayer)
             {
-                System.out.println("Media instance played. MRL: " + mediaInstance.getMediaDescriptor().getMrl());
+                System.out.println("Media instance played. MRL: " + mediaPlayer.getMediaDescriptor().getMrl());
             }
 
-            public void positionChanged(MediaPlayer mediaInstance)
+            public void positionChanged(MediaPlayer mediaPlayer)
             {
                 // TODO Auto-generated method stub
             }
 
-            public void timeChanged(MediaPlayer mediaInstance, long newTime)
+            public void timeChanged(MediaPlayer mediaPlayer, long newTime)
             {
                 System.out.println("new time: " + newTime);
             }
+
+            public void stopped(MediaPlayer mediaPlayer)
+            {
+                System.out.println("Media player stopped. MRL: " + mediaPlayer.getMediaDescriptor().getMrl());
+            }
         });
-        mediaInstance.play();
+        mediaPlayer.play();
 
-        while (!mediaInstance.hasVideoOutput())
+        while (!mediaPlayer.hasVideoOutput())
         {
             Thread.sleep(100);
         }
 
         Video video = new Video(jvlc);
-        System.out.print(video.getWidth(mediaInstance));
+        System.out.print(video.getWidth(mediaPlayer));
         System.out.print("x");
-        System.out.println(video.getHeight(mediaInstance));
+        System.out.println(video.getHeight(mediaPlayer));
         System.out.print("Fullscreen... ");
-        video.setFullscreen(mediaInstance, true);
+        video.setFullscreen(mediaPlayer, true);
         Thread.sleep(3000);
         System.out.println("real size.");
-        video.setFullscreen(mediaInstance, false);
+        video.setFullscreen(mediaPlayer, false);
         System.out.print("Taking snapshot... ");
-        video.getSnapshot(mediaInstance, System.getProperty("user.dir") + "/snap.png", 0, 0);
+        video.getSnapshot(mediaPlayer, System.getProperty("user.dir") + "/snap.png", 0, 0);
         System.out.println("taken. (see " + System.getProperty("user.dir") + "/snap.png )");
         Thread.sleep(2000);
         System.out.println("Resizing to 300x300");
@@ -95,15 +100,15 @@ public class VLCExample
         audio.setVolume(150);
         System.out.println("done");
         System.out.println("== AUDIO INFO ==");
-        System.out.println("Audio track number: " + audio.getTrack(mediaInstance));
+        System.out.println("Audio track number: " + audio.getTrack(mediaPlayer));
         System.out.println("Audio channel info: " + audio.getChannel());
         Thread.sleep(3000);
-        System.out.println("MEDIA INSTANCE INFORMATION");
+        System.out.println("MEDIA PLAYER INFORMATION");
         System.out.println("--------------------------");
-        System.out.println("Total length (ms) :\t" + mediaInstance.getLength());
-        System.out.println("Input time (ms) :\t" + mediaInstance.getTime());
-        System.out.println("Input position [0-1]:\t" + mediaInstance.getPosition());
-        System.out.println("Input FPS :\t" + mediaInstance.getFPS());
+        System.out.println("Total length (ms) :\t" + mediaPlayer.getLength());
+        System.out.println("Input time (ms) :\t" + mediaPlayer.getTime());
+        System.out.println("Input position [0-1]:\t" + mediaPlayer.getPosition());
+        System.out.println("Input FPS :\t" + mediaPlayer.getFPS());
 
         System.out.println("Everything fine ;)");
         return;