libvlc.h: Define and implement libvlc_media_instance_is_pausable().
authorPierre d'Herbemont <pdherbemont@videolan.org>
Mon, 7 Jan 2008 14:46:08 +0000 (14:46 +0000)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Mon, 7 Jan 2008 14:46:08 +0000 (14:46 +0000)
include/vlc/libvlc.h
src/control/media_instance.c

index ac15fd6..76a0757 100644 (file)
@@ -386,6 +386,10 @@ VLC_PUBLIC_API vlc_bool_t libvlc_media_instance_is_seekable(
                                  libvlc_media_instance_t *p_mi,
                                  libvlc_exception_t *p_e );
 
                                  libvlc_media_instance_t *p_mi,
                                  libvlc_exception_t *p_e );
 
+VLC_PUBLIC_API vlc_bool_t libvlc_media_instance_can_pause(
+                                 libvlc_media_instance_t *p_mi,
+                                 libvlc_exception_t *p_e );
+
 /** @}*/
 
 /*****************************************************************************
 /** @}*/
 
 /*****************************************************************************
index e428b15..f56c7af 100644 (file)
@@ -131,8 +131,12 @@ input_state_changed( vlc_object_t * p_this, char const * psz_cmd,
 {
     libvlc_media_instance_t * p_mi = p_userdata;
     libvlc_event_t event;
 {
     libvlc_media_instance_t * p_mi = p_userdata;
     libvlc_event_t event;
+    libvlc_event_type_t type = newval.i_int;
 
 
-    switch ( newval.i_int )
+    if( strcmp( psz_cmd, "state" ) )
+        type = var_GetBool( p_this, "state" );
+
+    switch ( type )
     {
         case END_S:
             libvlc_media_descriptor_set_state( p_mi->p_md, libvlc_NothingSpecial, NULL);
     {
         case END_S:
             libvlc_media_descriptor_set_state( p_mi->p_md, libvlc_NothingSpecial, NULL);
@@ -521,6 +525,7 @@ void libvlc_media_instance_play( libvlc_media_instance_t *p_mi,
     }
     var_AddCallback( p_input_thread, "state", input_state_changed, p_mi );
     var_AddCallback( p_input_thread, "seekable", input_state_changed, p_mi );
     }
     var_AddCallback( p_input_thread, "state", input_state_changed, p_mi );
     var_AddCallback( p_input_thread, "seekable", input_state_changed, p_mi );
+    var_AddCallback( p_input_thread, "pausable", input_state_changed, p_mi );
     var_AddCallback( p_input_thread, "intf-change", input_position_changed, p_mi );
     var_AddCallback( p_input_thread, "intf-change", input_time_changed, p_mi );
 
     var_AddCallback( p_input_thread, "intf-change", input_position_changed, p_mi );
     var_AddCallback( p_input_thread, "intf-change", input_time_changed, p_mi );
 
@@ -827,3 +832,24 @@ vlc_bool_t libvlc_media_instance_is_seekable(
 
     return val.b_bool;
 }
 
     return val.b_bool;
 }
+
+vlc_bool_t libvlc_media_instance_can_pause(
+                                 libvlc_media_instance_t *p_mi,
+                                 libvlc_exception_t *p_e )
+{
+    input_thread_t *p_input_thread;
+    vlc_value_t val;
+
+    p_input_thread = libvlc_get_input_thread ( p_mi, p_e );
+    if ( !p_input_thread )
+    {
+        /* We do return the right value, no need to throw an exception */
+        if( libvlc_exception_raised( p_e ) )
+            libvlc_exception_clear( p_e );
+        return VLC_FALSE;
+    }
+    var_Get( p_input_thread, "can-pause", &val );
+    vlc_object_release( p_input_thread );
+
+    return val.b_bool;
+}