]> git.sesse.net Git - vlc/blobdiff - src/control/playlist.c
(Forward port of [17371]) Implement Aspect Ratio property for Mozilla plugin
[vlc] / src / control / playlist.c
index 7070307c269c06a21d89b6674be4c1a039599922..cfe82b498b06798cd42e29056a3257296ed214e5 100644 (file)
 
 #include <vlc/intf.h>
 
+#include <assert.h>
+
+#define PL p_instance->p_libvlc_int->p_playlist
+
+void libvlc_playlist_loop( libvlc_instance_t *p_instance, vlc_bool_t loop,
+                           libvlc_exception_t *p_e)
+{
+    assert( PL );
+    var_SetBool(PL,"loop",loop);
+}
+
 void libvlc_playlist_play( libvlc_instance_t *p_instance, int i_id,
                            int i_options, char **ppsz_options,
-                           libvlc_exception_t *p_exception )
+                           libvlc_exception_t *p_e )
 {
+    assert( PL );
     ///\todo Handle additionnal options
 
-    if( p_instance->p_playlist->i_size == 0 )
-    {
-        libvlc_exception_raise( p_exception, "Empty playlist" );
-        return;
-    }
+    if( PL->items.i_size == 0 ) RAISEVOID( "Empty playlist" );
     if( i_id > 0 )
     {
-        /* Always use the current view when using libvlc */
-        playlist_view_t *p_view;
-        playlist_item_t *p_item;
-
-        if( p_instance->p_playlist->status.i_view == -1 )
-        {
-            playlist_Control( p_instance->p_playlist, PLAYLIST_GOTO,
-                              i_id );
-        }
-        p_view = playlist_ViewFind( p_instance->p_playlist,
-                                    p_instance->p_playlist->status.i_view );
-        if( !p_view )
-        {
-             libvlc_exception_raise( p_exception,
-                                     "Unable to find current playlist view ");
-             return;
-        }
-
-        p_item = playlist_ItemGetById( p_instance->p_playlist, i_id );
-
-        if( !p_item )
-        {
-            libvlc_exception_raise( p_exception, "Unable to find item " );
-            return;
-        }
-
-        playlist_Control( p_instance->p_playlist, PLAYLIST_VIEWPLAY,
-                          p_instance->p_playlist->status.i_view,
-                          p_view->p_root, p_item );
+        playlist_item_t *p_item = playlist_ItemGetById( PL,
+                                                        i_id );
+        if( !p_item ) RAISEVOID( "Unable to find item" );
+
+        playlist_LockControl( PL, PLAYLIST_VIEWPLAY,
+                              PL->status.p_node, p_item );
     }
     else
     {
-        playlist_Play( p_instance->p_playlist );
+        playlist_Play( PL );
     }
 }
 
+void libvlc_playlist_pause( libvlc_instance_t *p_instance,
+                           libvlc_exception_t *p_e )
+{
+    assert( PL );
+    if( playlist_Pause( PL ) != VLC_SUCCESS )
+        RAISEVOID( "Empty playlist" );
+}
+
+
 void libvlc_playlist_stop( libvlc_instance_t *p_instance,
-                           libvlc_exception_t *p_exception )
+                           libvlc_exception_t *p_e )
 {
-    if( playlist_Stop( p_instance->p_playlist ) != VLC_SUCCESS )
-    {
-        libvlc_exception_raise( p_exception, "Empty playlist" );
-    }
+    assert( PL );
+    if( playlist_Stop( PL ) != VLC_SUCCESS )
+        RAISEVOID( "Empty playlist" );
 }
 
 void libvlc_playlist_clear( libvlc_instance_t *p_instance,
-                           libvlc_exception_t *p_exception )
+                           libvlc_exception_t *p_e )
 {
-    playlist_Clear( p_instance->p_playlist );
+    assert( PL );
+    playlist_Clear( PL );
+}
+
+void libvlc_playlist_next( libvlc_instance_t *p_instance,
+                           libvlc_exception_t *p_e )
+{
+    assert( PL );
+    if( playlist_Next( PL ) != VLC_SUCCESS )
+        RAISEVOID( "Empty playlist" );
+}
+
+void libvlc_playlist_prev( libvlc_instance_t *p_instance,
+                           libvlc_exception_t *p_e )
+{
+    if( playlist_Prev( PL ) != VLC_SUCCESS )
+        RAISEVOID( "Empty playlist" );
 }
 
 int libvlc_playlist_add( libvlc_instance_t *p_instance, const char *psz_uri,
-                         const char *psz_name, libvlc_exception_t *p_exception )
+                         const char *psz_name, libvlc_exception_t *p_e )
 {
     return libvlc_playlist_add_extended( p_instance, psz_uri, psz_name,
-                                         0, NULL, p_exception );
+                                         0, NULL, p_e );
 }
 
 int libvlc_playlist_add_extended( libvlc_instance_t *p_instance,
                                   const char *psz_uri, const char *psz_name,
                                   int i_options, const char **ppsz_options,
-                                  libvlc_exception_t *p_exception )
+                                  libvlc_exception_t *p_e )
 {
-    return playlist_AddExt( p_instance->p_playlist, psz_uri, psz_name,
+    assert( PL );
+    return playlist_PlaylistAddExt( PL, psz_uri, psz_name,
                             PLAYLIST_INSERT, PLAYLIST_END, -1, ppsz_options,
                             i_options );
 }
 
+int libvlc_playlist_delete_item( libvlc_instance_t *p_instance, int i_id,
+                                 libvlc_exception_t *p_e )
+{
+    assert( PL );
+    return playlist_DeleteFromItemId( PL, i_id );
+}
+
 
+int libvlc_playlist_isplaying( libvlc_instance_t *p_instance,
+                               libvlc_exception_t *p_e )
+{
+    assert( PL );
+    return playlist_IsPlaying( PL );
+}
+
+int libvlc_playlist_items_count( libvlc_instance_t *p_instance,
+                                 libvlc_exception_t *p_e )
+{
+    assert( PL );
+    return PL->items.i_size;
+}
 
 libvlc_input_t * libvlc_playlist_get_input( libvlc_instance_t *p_instance,
-                                            libvlc_exception_t *p_exception )
+                                            libvlc_exception_t *p_e )
 {
     libvlc_input_t *p_input;
+    assert( PL );
 
-    vlc_mutex_lock( &p_instance->p_playlist->object_lock );
-    if( p_instance->p_playlist->p_input == NULL )
+    vlc_mutex_lock( &PL->object_lock );
+    if( PL->p_input == NULL )
     {
-        libvlc_exception_raise( p_exception, "No active input" );
-        vlc_mutex_unlock( &p_instance->p_playlist->object_lock );
+        libvlc_exception_raise( p_e, "No active input" );
+        vlc_mutex_unlock( &PL->object_lock );
         return NULL;
     }
     p_input = (libvlc_input_t *)malloc( sizeof( libvlc_input_t ) );
 
-    p_input->i_input_id = p_instance->p_playlist->p_input->i_object_id;
+    p_input->i_input_id = PL->p_input->i_object_id;
     p_input->p_instance = p_instance;
-    vlc_mutex_unlock( &p_instance->p_playlist->object_lock );
+    vlc_mutex_unlock( &PL->object_lock );
 
     return p_input;
 }