Commit 76ca9001 authored by Filippo Carone's avatar Filippo Carone

libvlc, jvlc: media_player_is_playing method added

parent d7ee744d
......@@ -151,6 +151,12 @@ public class MediaPlayer
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)
{
MediaPlayerCallback callback = new MediaPlayerCallback(this, listener);
......
......@@ -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);
......
......@@ -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()
{
......
......@@ -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
*
......
......@@ -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
**************************************************************************/
......
......@@ -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
......
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