diff options
author | lvw <lvw@e10066b5-e1e2-0310-b819-94efdf66514b> | 2004-09-24 06:07:55 +0000 |
---|---|---|
committer | lvw <lvw@e10066b5-e1e2-0310-b819-94efdf66514b> | 2004-09-24 06:07:55 +0000 |
commit | 0ff09355725ac5cc52124b0d29472ca30135430c (patch) | |
tree | b321f9e54bffde9269299a1df2feb2f9411e9bea | |
parent | 63b6bd44d76c0d4c9c2177ca129aaa8fd3dc9f44 (diff) | |
download | vdr-plugin-muggle-0ff09355725ac5cc52124b0d29472ca30135430c.tar.gz vdr-plugin-muggle-0ff09355725ac5cc52124b0d29472ca30135430c.tar.bz2 |
Improved playlist handling (skipping)
git-svn-id: https://vdr-muggle.svn.sourceforge.net/svnroot/vdr-muggle/trunk/muggle-plugin@173 e10066b5-e1e2-0310-b819-94efdf66514b
-rw-r--r-- | TODO | 22 | ||||
-rw-r--r-- | mg_playlist.c | 56 | ||||
-rw-r--r-- | vdr_player.c | 75 |
3 files changed, 110 insertions, 43 deletions
@@ -76,14 +76,19 @@ - generate a random number 0..n-1 - move corresponding playlist item to front - continue - - Party mode (see iTunes) - - generate a random uid - - if file exists: - - determine maximum playcount of all tracks - - generate a random number n - - if n < playcount / max. playcount - - play the file - + - Party mode (see iTunes) + - initialization + - find 15 titles according to the scheme below + - playing + - before entering next title perform track selection + - track selection + - generate a random uid + - if file exists: + - determine maximum playcount of all tracks + - generate a random number n + - if n < playcount / max. playcount + - add the file to the end of the list + \subsection urgentplayer Player extensions - Determine max. framecount (needed for rewinding)? @@ -175,6 +180,7 @@ - Display covers - Add flac decoder + - Handle recoding samplerate, limiter etc correctly \section vision Long term ideas and visions diff --git a/mg_playlist.c b/mg_playlist.c index 83bdbd8..82df4cb 100644 --- a/mg_playlist.c +++ b/mg_playlist.c @@ -1,11 +1,11 @@ /*! * \file mg_playlist.c - * \brief defines functions to be executed on playlists for the vdr muggle plugindatabase + * \brief defines functions to be executed on playlists for the vdr muggle plugin * * \version $Revision: 1.6 $ - * \date $Date: 2004/07/27 20:50:54 $ + * \date $Date$ * \author Ralf Klueber, Lars von Wedel, Andreas Kellner - * \author Responsible author: $Author: lvw $ + * \author Responsible author: $Author$ * * This file implements the class mgPlaylist which maintains a playlist * and supports editing (e.g. adding or moving tracks), navigating it @@ -17,6 +17,7 @@ #include "mg_tools.h" #include <vector> +#include <iostream> using namespace std; @@ -84,14 +85,14 @@ void mgPlaylist::appendList( vector<mgContentItem*> *tracks ) /* add a song after 'position' */ void mgPlaylist::insert( mgContentItem* item, unsigned int position ) { - if( position >= m_list.size() ) - { - m_list.push_back(item); - } - else - { - m_list.insert( m_list.begin() + position, item ); - } + if( position >= m_list.size() ) + { + m_list.push_back(item); + } + else + { + m_list.insert( m_list.begin() + position, item ); + } } void mgPlaylist::clear() @@ -107,6 +108,9 @@ void mgPlaylist::clear() // finally clear the list itself m_list.clear(); + + // reset index + m_current_idx = 0; } void mgPlaylist::move( int from, int to ) @@ -116,6 +120,15 @@ void mgPlaylist::move( int from, int to ) m_list.insert( to_iter, *from_iter); m_list.erase( from_iter ); + + if( from < m_current_idx ) + { + m_current_idx--; + } + if( to < m_current_idx ) + { + m_current_idx++; + } } /*==== access tracks ====*/ @@ -135,18 +148,28 @@ int mgPlaylist::count() return m_list.size(); } -// returns the first item of the list +// returns the current item of the list mgContentItem* mgPlaylist::getCurrent() { - return *( m_list.begin() + m_current_idx ); + mgContentItem *result; + + if( 0 <= m_current_idx && m_current_idx < m_list.size() ) + { + result = *( m_list.begin() + m_current_idx ); + } + else + { + result = &(mgContentItem::UNDEFINED); + } + + return result; } -// returns the nth track from the playlist +// returns the nth track from the playlist void mgPlaylist::gotoPosition(unsigned int position) { if( position >= m_list.size() ) { - // TODO: why not return a NULL pointer? LVW m_current_idx = -1; } else @@ -160,7 +183,8 @@ void mgPlaylist::skipFwd() { if( m_current_idx + 1 < m_list.size() ) // unless loop mode { - m_current_idx ++; + m_current_idx ++; + cout << "mgPlaylist::skipFwd: " << m_current_idx << endl; } else { diff --git a/vdr_player.c b/vdr_player.c index 6161dd9..32ca216 100644 --- a/vdr_player.c +++ b/vdr_player.c @@ -363,22 +363,24 @@ void mgPCMPlayer::Action(void) m_index = 0; m_playing = m_current; - string filename = m_playing->getSourceFile(); - mgDebug( 1, "mgPCMPlayer::Action: music file is %s", filename.c_str() ); + if( m_playing && m_playing != &(mgContentItem::UNDEFINED) ) + { + string filename = m_playing->getSourceFile(); + // mgDebug( 1, "mgPCMPlayer::Action: music file is %s", filename.c_str() ); - if( ( m_decoder = mgDecoders::findDecoder( m_playing ) ) && m_decoder->start() ) - { - levelgood = true; - haslevel = false; - - scale.Init(); - level.Init(); - - m_state = msDecode; + if( ( m_decoder = mgDecoders::findDecoder( m_playing ) ) && m_decoder->start() ) + { + levelgood = true; + haslevel = false; - break; - } - + scale.Init(); + level.Init(); + + m_state = msDecode; + + break; + } + } m_state = msEof; } break; case msDecode: @@ -673,17 +675,52 @@ void mgPCMPlayer::StopPlay() bool mgPCMPlayer::NextFile() { + mgContentItem *newcurr; + bool res = false; - - m_playlist->skipFwd(); - mgContentItem *newcurr = m_playlist->getCurrent(); + bool m_partymode = false; + bool m_shufflemode = false; + if( m_partymode ) + { + /* + - Party mode (see iTunes) + - initialization + - find 15 titles according to the scheme below + - playing + - before entering next title perform track selection + - track selection + - generate a random uid + - if file exists: + - determine maximum playcount of all tracks + - generate a random number n + - if n < playcount / max. playcount + - add the file to the end of the list + */ + } + else if( m_shufflemode ) + { + /* + - Handle shuffle mode in mgPlaylist + - for next file: + - generate a random number 0..n-1 + - move corresponding playlist item to front + - continue + */ + + } + else + { + m_playlist->skipFwd(); + newcurr = m_playlist->getCurrent(); + } + if( newcurr && newcurr != &(mgContentItem::UNDEFINED) ) { m_current = newcurr; res = true; } - + return res; } @@ -735,7 +772,7 @@ void mgPCMPlayer::Play(void) Lock(); - if( m_playmode != pmPlay && m_current ) + if( m_playmode != pmPlay && m_current && m_current != &(mgContentItem::UNDEFINED) ) { if( m_playmode == pmStopped ) { |