]> git.sesse.net Git - vlc/blobdiff - lib/media_list_player.c
update meta request API to allow overriding
[vlc] / lib / media_list_player.c
index 343866bb75eea21dd4725eb72aa6009429fde6c8..d0a0ce16ff26ef890e55db63e3fd6669b5af0d22 100644 (file)
@@ -1,24 +1,24 @@
 /*****************************************************************************
  * media_list_player.c: libvlc new API media_list player functions
  *****************************************************************************
- * Copyright (C) 2007 the VideoLAN team
+ * Copyright (C) 2007 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #ifdef HAVE_CONFIG_H
@@ -470,7 +470,10 @@ libvlc_media_list_player_new(libvlc_instance_t * p_instance)
     p_mlp->i_refcount = 1;
     vlc_mutex_init(&p_mlp->object_lock);
     vlc_mutex_init(&p_mlp->mp_callback_lock);
-    libvlc_event_manager_register_event_type(p_mlp->p_event_manager, libvlc_MediaListPlayerNextItemSet);
+    libvlc_event_manager_register_event_type( p_mlp->p_event_manager,
+            libvlc_MediaListPlayerNextItemSet );
+    libvlc_event_manager_register_event_type( p_mlp->p_event_manager,
+            libvlc_MediaListPlayerStopped );
     p_mlp->e_playback_mode = libvlc_playback_mode_default;
 
     return p_mlp;
@@ -646,14 +649,18 @@ libvlc_media_list_player_get_state(libvlc_media_list_player_t * p_mlp)
 int libvlc_media_list_player_play_item_at_index(libvlc_media_list_player_t * p_mlp, int i_index)
 {
     lock(p_mlp);
-    set_current_playing_item(p_mlp, libvlc_media_list_path_with_root_index(i_index));
+    libvlc_media_list_path_t path = libvlc_media_list_path_with_root_index(i_index);
+    set_current_playing_item(p_mlp, path);
     libvlc_media_player_play(p_mlp->p_mi);
     unlock(p_mlp);
 
     /* Send the next item event */
     libvlc_event_t event;
     event.type = libvlc_MediaListPlayerNextItemSet;
+    libvlc_media_t * p_md = libvlc_media_list_item_at_path(p_mlp->p_mlist, path);
+    event.u.media_list_player_next_item_set.item = p_md;
     libvlc_event_send(p_mlp->p_event_manager, &event);
+    libvlc_media_release(p_md);
     return 0;
 }
 
@@ -696,6 +703,11 @@ static void stop(libvlc_media_list_player_t * p_mlp)
 
     free(p_mlp->current_playing_item_path);
     p_mlp->current_playing_item_path = NULL;
+
+    /* Send the event */
+    libvlc_event_t event;
+    event.type = libvlc_MediaListPlayerStopped;
+    libvlc_event_send(p_mlp->p_event_manager, &event);
 }
 
 /**************************************************************************