control/media_list.c: Handle libvlc_MediaDescriptorSubItemAdded event.
authorPierre d'Herbemont <pdherbemont@videolan.org>
Thu, 16 Aug 2007 18:05:43 +0000 (18:05 +0000)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Thu, 16 Aug 2007 18:05:43 +0000 (18:05 +0000)
src/control/media_list.c

index bf06917..077b0da 100644 (file)
@@ -98,6 +98,23 @@ media_descriptor_changed( const libvlc_event_t * p_event, void * user_data )
     libvlc_event_send( p_mlist->p_event_manager, &event );
 }
 
+/**************************************************************************
+ *       media_descriptor_subitem_added (private) (libvlc Event Callback )
+ *
+ * An item (which is a playlist) has gained sub child.
+ **************************************************************************/
+static void
+media_descriptor_subitem_added( const libvlc_event_t * p_event, void * user_data )
+{
+    libvlc_media_list_t * p_mlist = user_data;
+    libvlc_media_descriptor_t * p_new_md;
+
+    p_new_md = p_event->u.media_descriptor_subitem_added.new_child;
+
+    /* For now, just add the new item to this media list */
+    libvlc_media_list_add_media_descriptor( p_mlist, p_new_md, NULL );
+}
+
 /**************************************************************************
  *       install_media_descriptor_observer (private)
  *
@@ -111,6 +128,10 @@ install_media_descriptor_observer( libvlc_media_list_t * p_mlist,
                          libvlc_MediaDescriptorMetaChanged,
                          media_descriptor_changed,
                          p_mlist, NULL );
+    libvlc_event_attach( p_md->p_event_manager,
+                         libvlc_MediaDescriptorSubItemAdded,
+                         media_descriptor_changed,
+                         p_mlist, NULL );
 }
 
 /**************************************************************************
@@ -126,6 +147,10 @@ uninstall_media_descriptor_observer( libvlc_media_list_t * p_mlist,
                          libvlc_MediaDescriptorMetaChanged,
                          media_descriptor_changed,
                          p_mlist, NULL );
+    libvlc_event_detach( p_md->p_event_manager,
+                         libvlc_MediaDescriptorSubItemAdded,
+                         media_descriptor_changed,
+                         p_mlist, NULL );
 }
 
 /**************************************************************************