]> git.sesse.net Git - vlc/commitdiff
libvlc, jvlc: media_player_is_playing method added
authorFilippo Carone <littlejohn@videolan.org>
Tue, 6 Jan 2009 21:48:03 +0000 (22:48 +0100)
committerFilippo Carone <littlejohn@videolan.org>
Tue, 6 Jan 2009 21:48:15 +0000 (22:48 +0100)
bindings/java/core/src/main/java/org/videolan/jvlc/MediaListPlayer.java
bindings/java/core/src/main/java/org/videolan/jvlc/MediaPlayer.java
bindings/java/core/src/main/java/org/videolan/jvlc/internal/LibVlc.java
bindings/java/core/src/test/java/org/videolan/jvlc/internal/LibVlcMediaPlayerTest.java
include/vlc/libvlc.h
src/control/media_player.c
src/libvlc.sym

index 2a073b9821161147dde15a16b499583728494d29..b5e9a72c45f29a60fa36304111e96ad4a8f52777 100644 (file)
@@ -35,7 +35,7 @@ public class MediaListPlayer
     private final LibVlcMediaListPlayer instance;
 
     private final JVLC jvlc;
-
+    
     public MediaListPlayer(JVLC jvlc)
     {
         libvlc_exception_t exception = new libvlc_exception_t();
index 5377e995706617bf735b2399dc19874be7c170b0..da069b6bae475e749dfb9e92aff6dbf131703761 100644 (file)
@@ -150,6 +150,12 @@ public class MediaPlayer
         libvlc_exception_t exception = new libvlc_exception_t();
         return libvlc.libvlc_media_player_get_fps(instance, exception);
     }
+    
+    public boolean isPlaying()
+    {
+        libvlc_exception_t exception = new libvlc_exception_t();
+        return libvlc.libvlc_media_player_is_playing(instance, exception) == 1? true : false;
+    }
 
     public void addListener(final MediaPlayerListener listener)
     {
index a3c29b2d55f642884ef940e91111bb0c7fe156fa..97aa592a66b9ec89695d4424e5a243cff65e8326 100644 (file)
@@ -454,6 +454,8 @@ public interface LibVlc extends Library
 
     void libvlc_media_player_set_position(LibVlcMediaPlayer instance, float position, libvlc_exception_t exception);
 
+    int libvlc_media_player_is_playing(LibVlcMediaPlayer instance, libvlc_exception_t exception);
+    
     int libvlc_media_player_will_play(LibVlcMediaPlayer instance, libvlc_exception_t exception);
 
     void libvlc_media_player_set_rate(LibVlcMediaPlayer instance, float rate, libvlc_exception_t exception);
index c96602ada33b615c491c601cd0e0531d0d7a1365..8cda2464afc5426d6376fad851d45b162345eea6 100644 (file)
@@ -58,6 +58,18 @@ public class LibVlcMediaPlayerTest extends AbstractVLCInternalTest
         Assert.assertEquals(0, exception.raised);
     }
     
+    @Test
+    public void mediaPlayerIsPlaying() throws Exception
+    {
+        LibVlcMedia md = libvlc.libvlc_media_new(libvlcInstance, mrl, exception);
+        LibVlcMediaPlayer mi = libvlc.libvlc_media_player_new_from_media(md, exception);
+        Assert.assertEquals(0, libvlc.libvlc_media_player_is_playing(mi, exception));
+        libvlc.libvlc_media_player_play(mi, exception);
+        Assert.assertEquals(0, exception.raised);
+        Thread.sleep(200);
+        Assert.assertEquals(1, libvlc.libvlc_media_player_is_playing(mi, exception));
+    }
+    
     @Test
     public void mediaPlayerPauseBad()
     {
index 182bfca467e36f08f1bfbfbbd90595e561513287..f2254d7c23faf467273eb793a4dd6f3dc4be2009 100644 (file)
@@ -498,6 +498,15 @@ VLC_PUBLIC_API libvlc_media_t * libvlc_media_player_get_media( libvlc_media_play
  */
 VLC_PUBLIC_API libvlc_event_manager_t * libvlc_media_player_event_manager ( libvlc_media_player_t *, libvlc_exception_t * );
 
+/**
+ * is_playing
+ *
+ * \param p_mi the Media Player
+ * \param p_e an initialized exception pointer
+ * \return 1 if the media player is playing, 0 otherwise
+ */
+VLC_PUBLIC_API int libvlc_media_player_is_playing ( libvlc_media_player_t *, libvlc_exception_t * );
+
 /**
  * Play
  *
index 7dbbb0cd2f90db91672a76870211f214d27100e8..87788ccd53d3855fee65fdf3855232245b796908 100644 (file)
@@ -633,6 +633,29 @@ void libvlc_media_player_pause( libvlc_media_player_t *p_mi,
     vlc_object_release( p_input_thread );
 }
 
+/**************************************************************************
+ * is_playing
+ **************************************************************************/
+int libvlc_media_player_is_playing( libvlc_media_player_t *p_mi,
+                                     libvlc_exception_t *p_e )
+{
+    input_thread_t * p_input_thread = libvlc_get_input_thread( p_mi, p_e );
+
+    if( !p_input_thread )
+        return 0;
+
+    libvlc_state_t state = libvlc_media_player_get_state( p_mi, p_e );
+
+    vlc_object_release( p_input_thread );
+    
+    if( state == libvlc_Playing )
+    {
+        return 1;
+    }
+    return 0;
+}
+
+
 /**************************************************************************
  * Stop
  **************************************************************************/
index 3a0229504ff2b94cab42f61e6c07ac6115fc5787..430ca717952cd9ecbd7ce4f94c880e34ac86454b 100644 (file)
@@ -134,6 +134,7 @@ libvlc_media_player_get_title
 libvlc_media_player_get_title_count
 libvlc_media_player_has_vout
 libvlc_media_player_is_seekable
+libvlc_media_player_is_playing
 libvlc_media_player_new
 libvlc_media_player_new_from_input_thread
 libvlc_media_player_new_from_media