[vlc-devel] commit: Add playlist_CurrentId() to get the playlist item id from the currently playing item. ( Jean-Paul Saman )
git version control
git at videolan.org
Sat Jun 14 11:05:48 CEST 2008
vlc | branch: master | Jean-Paul Saman <jpsaman at videolan.org> | Fri Jun 13 16:18:55 2008 +0200| [ef7ff281ab3587a43786529cb67704752c8148b5]
Add playlist_CurrentId() to get the playlist item id from the currently playing item.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ef7ff281ab3587a43786529cb67704752c8148b5
---
include/vlc/deprecated.h | 2 ++
include/vlc_playlist.h | 3 +++
projects/activex/vlccontrol.cpp | 17 ++++++++++++-----
src/control/playlist.c | 13 ++++++++++++-
src/libvlc.sym | 1 +
5 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/include/vlc/deprecated.h b/include/vlc/deprecated.h
index 92737b0..0238e5d 100644
--- a/include/vlc/deprecated.h
+++ b/include/vlc/deprecated.h
@@ -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.
*
diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h
index 1dcd245..4983b0b 100644
--- a/include/vlc_playlist.h
+++ b/include/vlc_playlist.h
@@ -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 )
diff --git a/projects/activex/vlccontrol.cpp b/projects/activex/vlccontrol.cpp
index 1921014..45347f7 100644
--- a/projects/activex/vlccontrol.cpp
+++ b/projects/activex/vlccontrol.cpp
@@ -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)
diff --git a/src/control/playlist.c b/src/control/playlist.c
index ae9217f..0300243 100644
--- a/src/control/playlist.c
+++ b/src/control/playlist.c
@@ -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 );
diff --git a/src/libvlc.sym b/src/libvlc.sym
index 1e77430..f3b8eb1 100644
--- a/src/libvlc.sym
+++ b/src/libvlc.sym
@@ -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
More information about the vlc-devel
mailing list