Add playlist_CurrentId() to get the playlist item id from the currently playing item.
authorJean-Paul Saman <jpsaman@videolan.org>
Fri, 13 Jun 2008 14:18:55 +0000 (16:18 +0200)
committerJean-Paul Saman <jpsaman@videolan.org>
Sat, 14 Jun 2008 08:09:06 +0000 (10:09 +0200)
include/vlc/deprecated.h
include/vlc_playlist.h
projects/activex/vlccontrol.cpp
src/control/playlist.c
src/libvlc.sym

index 92737b0..0238e5d 100644 (file)
@@ -127,6 +127,8 @@ VLC_DEPRECATED_API int libvlc_playlist_isplaying( libvlc_instance_t *,
 VLC_DEPRECATED_API int libvlc_playlist_items_count( libvlc_instance_t *,
                                                 libvlc_exception_t * );
 
+VLC_DEPRECATED_API int libvlc_playlist_get_current_index( libvlc_instance_t *,
+                                                 libvlc_exception_t *);
 /**
  * Lock the playlist.
  *
index 1dcd245..4983b0b 100644 (file)
@@ -420,6 +420,9 @@ static inline int playlist_Import( playlist_t *p_playlist, const char *psz_file)
 /** Tell the number of items in the current playing context */
 #define playlist_CurrentSize( pl ) pl->current.i_size
 
+/** Tell the current item id in current  playing context */
+#define playlist_CurrentId( pl ) pl->status.p_item->i_id
+
 /** Ask the playlist to do some work */
 #define playlist_Signal( p_playlist ) vlc_object_signal( p_playlist )
 
index 1921014..45347f7 100644 (file)
@@ -890,21 +890,28 @@ STDMETHODIMP VLCControl::addTarget(BSTR uri, VARIANT options, enum VLCPlaylistMo
 
 STDMETHODIMP VLCControl::get_PlaylistIndex(int *index)
 {
-    return E_INVALIDARG;
-#if 0
     if( NULL == index )
         return E_POINTER;
 
+    *index = 0;
     libvlc_instance_t *p_libvlc;
     HRESULT result = _p_instance->getVLC(&p_libvlc);
     if( SUCCEEDED(result) )
     {
-        *index = VLC_PlaylistIndex(i_vlc);
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        *index = libvlc_playlist_get_current_index(p_libvlc, &ex);
+        if( libvlc_exception_raised(&ex) )
+        {
+            _p_instance->setErrorInfo(IID_IVLCControl,
+                libvlc_exception_get_message(&ex));
+            libvlc_exception_clear(&ex);
+            return E_FAIL;
+        }
         return NOERROR;
     }
-    *index = 0;
     return result;
-#endif
 };
 
 STDMETHODIMP VLCControl::get_PlaylistCount(int *count)
index ae9217f..0300243 100644 (file)
@@ -62,7 +62,7 @@ void libvlc_playlist_play( libvlc_instance_t *p_instance, int i_id,
                            int i_options, char **ppsz_options,
                            libvlc_exception_t *p_e )
 {
-    VLC_UNUSED(p_e);
+    VLC_UNUSED(p_e); VLC_UNUSED(i_options); VLC_UNUSED(ppsz_options);
 
     int did_lock = 0;
     assert( PL );
@@ -208,6 +208,17 @@ int libvlc_playlist_items_count( libvlc_instance_t *p_instance,
     return playlist_CurrentSize( PL );
 }
 
+int libvlc_playlist_get_current_index ( libvlc_instance_t *p_instance,
+                                        libvlc_exception_t *p_e )
+{
+    VLC_UNUSED(p_e);
+
+    assert( PL );
+    if( !PL->status.p_item )
+        return -1;
+    return playlist_CurrentId( PL );
+}
+
 void libvlc_playlist_lock( libvlc_instance_t *p_instance )
 {
     assert( PL );
index 1e77430..f3b8eb1 100644 (file)
@@ -148,6 +148,7 @@ libvlc_playlist_delete_item
 libvlc_playlist_get_media_player
 libvlc_playlist_isplaying
 libvlc_playlist_items_count
+libvlc_playlist_get_current_index
 libvlc_playlist_lock
 libvlc_playlist_loop
 libvlc_playlist_next