From 990943fcd5defcc86bedfc6d386a71263576a81b Mon Sep 17 00:00:00 2001 From: phintuka Date: Thu, 9 Dec 2010 14:13:03 +0000 Subject: Added cPlaylist::Seek() --- tools/playlist.c | 19 ++++++++++++++++++- tools/playlist.h | 3 ++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/tools/playlist.c b/tools/playlist.c index f91a67f5..c517bd46 100644 --- a/tools/playlist.c +++ b/tools/playlist.c @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: playlist.c,v 1.31 2010-11-17 13:07:28 phintuka Exp $ + * $Id: playlist.c,v 1.32 2010-12-09 14:13:03 phintuka Exp $ * */ @@ -524,6 +524,23 @@ cPlaylistItem *cPlaylist::Prev(void) return NULL; } +cPlaylistItem *cPlaylist::Seek(int Rel) +{ + cMutexLock ml(&m_Lock); + if (!Current()) + return NULL; + + if (Rel > 0) + while (Rel--) + m_Current = (cList::Next(Current()) ?: Last()); + + if (Rel < 0) + while (Rel++) + m_Current = (cList::Prev(Current()) ?: First()); + + return Current(); +} + bool cPlaylist::StoreCache(void) { if(!xc.cache_implicit_playlists || diff --git a/tools/playlist.h b/tools/playlist.h index d7de7622..641ff175 100644 --- a/tools/playlist.h +++ b/tools/playlist.h @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: playlist.h,v 1.13 2010-09-13 11:39:34 phintuka Exp $ + * $Id: playlist.h,v 1.14 2010-12-09 14:13:03 phintuka Exp $ * */ @@ -124,6 +124,7 @@ class cPlaylist : protected cList void SetCurrent(cPlaylistItem *current); cPlaylistItem *Next(void); cPlaylistItem *Prev(void); + cPlaylistItem *Seek(int Rel); static cString BuildMrl(const char *proto, const char *s1, const char *s2 = NULL, const char *s3 = NULL, const char *s4 = NULL); -- cgit v1.2.3