summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlvw <lvw@e10066b5-e1e2-0310-b819-94efdf66514b>2004-10-25 15:22:18 +0000
committerlvw <lvw@e10066b5-e1e2-0310-b819-94efdf66514b>2004-10-25 15:22:18 +0000
commita754aba317b7d855d87e881b681569a46a14bb83 (patch)
tree88f1979af5cc3bd321e8e57b9397122c38ad94be
parent049852735e5d91b183eb28229e32de5f1a563fd1 (diff)
downloadvdr-plugin-muggle-a754aba317b7d855d87e881b681569a46a14bb83.tar.gz
vdr-plugin-muggle-a754aba317b7d855d87e881b681569a46a14bb83.tar.bz2
Added feature to resume
git-svn-id: https://vdr-muggle.svn.sourceforge.net/svnroot/vdr-muggle/trunk/muggle-plugin@243 e10066b5-e1e2-0310-b819-94efdf66514b
-rw-r--r--muggle.c12
-rw-r--r--muggle.h4
-rw-r--r--vdr_menu.c11
-rw-r--r--vdr_menu.h2
-rw-r--r--vdr_player.c49
-rw-r--r--vdr_player.h2
6 files changed, 35 insertions, 45 deletions
diff --git a/muggle.c b/muggle.c
index 8a00883..00d747e 100644
--- a/muggle.c
+++ b/muggle.c
@@ -26,6 +26,7 @@ static const char *VERSION = "0.0.8";
static const char *DESCRIPTION = "Media juggle plugin for VDR";
static const char *MAINMENUENTRY = "Muggle";
+static unsigned s_resume_idx = 0;
const char* mgMuggle::Version(void)
{
@@ -215,4 +216,15 @@ bool mgMuggle::SetupParse(const char *Name, const char *Value)
return true;
}
+
+static void mgMuggle::setResumeIndex( unsigned index )
+{
+ s_resume_idx = index;
+}
+
+static unsigned mgMuggle::getResumeIndex( )
+{
+ return s_resume_idx;
+}
+
VDRPLUGINCREATOR(mgMuggle); // Don't touch this!
diff --git a/muggle.h b/muggle.h
index 3c61646..4377359 100644
--- a/muggle.h
+++ b/muggle.h
@@ -71,6 +71,10 @@ public:
virtual bool SetupParse(const char *Name, const char *Value);
+ static void setResumeIndex( unsigned index );
+
+ static unsigned getResumeIndex( );
+
private:
mgMedia *m_media;
diff --git a/vdr_menu.c b/vdr_menu.c
index bea0db0..1f54e21 100644
--- a/vdr_menu.c
+++ b/vdr_menu.c
@@ -292,14 +292,16 @@ eOSState mgMainMenu::ProcessKey(eKeys key)
case kOk:
{
// start replay at selected index
- int idx = Current();
+ unsigned idx = Current();
Play( m_current_playlist, idx );
state = osContinue;
} break;
case kRed:
{
// TODO: what happens if the user presses play and the player is already active?
- Play( m_current_playlist );
+ // TODO: resume?
+ unsigned resume = mgMuggle::getResumeIndex();
+ Play( m_current_playlist, resume );
state = osEnd;
} break;
case kGreen:
@@ -571,7 +573,8 @@ eOSState mgMainMenu::TreeSubmenuAction( int n )
m_current_playlist->appendList( tracks );
// play
- Play( m_current_playlist );
+ mgMuggle::setResumeIndex( 0 );
+ Play( m_current_playlist, 0 );
state = osEnd;
}
@@ -954,7 +957,7 @@ void mgMainMenu::DisplayFilterSelector()
// show available filters, load on OK?
}
-void mgMainMenu::Play( mgPlaylist *plist, int first )
+void mgMainMenu::Play( mgPlaylist *plist, unsigned first )
{
MGLOG( "mgMainMenu::Play" );
cControl *control = cControl::Control();
diff --git a/vdr_menu.h b/vdr_menu.h
index 41bba01..4c618c3 100644
--- a/vdr_menu.h
+++ b/vdr_menu.h
@@ -99,7 +99,7 @@ class mgMainMenu : public cOsdMenu
private:
//! \brief launch the actual player
- void Play( mgPlaylist *plist, int first = -1 );
+ void Play( mgPlaylist *plist, unsigned first );
// content stuff
mgMedia *m_media;
diff --git a/vdr_player.c b/vdr_player.c
index bd05767..9365090 100644
--- a/vdr_player.c
+++ b/vdr_player.c
@@ -203,7 +203,7 @@ public:
virtual bool GetIndex(int &Current, int &Total, bool SnapToIFrame=false);
// bool GetPlayInfo(cMP3PlayInfo *rm); // LVW
- void NewPlaylist( mgPlaylist *plist, int first );
+ void NewPlaylist( mgPlaylist *plist, unsigned first );
mgContentItem *getCurrent () { return m_current; }
mgPlaylist *getPlaylist () { return m_playlist; }
};
@@ -699,51 +699,20 @@ bool mgPCMPlayer::NextFile( )
mgContentItem *newcurr;
bool res = false;
- bool m_partymode = false;
- bool m_shufflemode = false;
- if( m_partymode )
+ if( m_playlist->skipFwd() )
{
- /*
- - 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
- */
+ newcurr = m_playlist->getCurrent();
}
else
{
- if( m_playlist->skipFwd() )
- {
- newcurr = m_playlist->getCurrent();
- }
- else
- {
- newcurr = &(mgContentItem::UNDEFINED);
- }
+ newcurr = &(mgContentItem::UNDEFINED);
}
if( newcurr && newcurr != &(mgContentItem::UNDEFINED) )
{
m_current = newcurr;
+ mgMuggle::setResumeIndex( m_playlist->getIndex() );
res = true;
}
@@ -760,7 +729,8 @@ bool mgPCMPlayer::PrevFile(void)
if( newcurr && newcurr != &(mgContentItem::UNDEFINED) )
{
- m_current = newcurr;
+ m_current = newcurr;
+ mgMuggle::setResumeIndex( m_playlist->getIndex() );
res = true;
}
}
@@ -1105,7 +1075,7 @@ void mgPCMPlayer::send_pes_packet(unsigned char *data, int len, int timestamp)
// --- mgPlayerControl -------------------------------------------------------
-mgPlayerControl::mgPlayerControl( mgPlaylist *plist, int start )
+mgPlayerControl::mgPlayerControl( mgPlaylist *plist, unsigned start )
: cControl( player = new mgPCMPlayer( plist, start ) )
{
MGLOG( "mgPlayerControl::mgPlayerControl" );
@@ -1217,7 +1187,7 @@ void mgPlayerControl::ToggleLoop(void)
}
}
-void mgPlayerControl::NewPlaylist(mgPlaylist *plist, int start)
+void mgPlayerControl::NewPlaylist(mgPlaylist *plist, unsigned start)
{
if( player )
{
@@ -1586,6 +1556,7 @@ eOSState mgPlayerControl::ProcessKey(eKeys key)
{
InternalHide();
Stop();
+ mgMuggle::setResumeIndex( 0 );
return osEnd;
} break;
diff --git a/vdr_player.h b/vdr_player.h
index 2c73771..af39429 100644
--- a/vdr_player.h
+++ b/vdr_player.h
@@ -121,7 +121,7 @@ public:
* \param plist - the new playlist to be played
* \param first - the index where to start the playlist
*/
- void NewPlaylist( mgPlaylist *plist, int start );
+ void NewPlaylist( mgPlaylist *plist, unsigned start );
//! \brief a progress display
void ShowProgress();