summaryrefslogtreecommitdiff
path: root/media_player.c
diff options
context:
space:
mode:
Diffstat (limited to 'media_player.c')
-rw-r--r--media_player.c93
1 files changed, 38 insertions, 55 deletions
diff --git a/media_player.c b/media_player.c
index 0cd2502e..dd437b16 100644
--- a/media_player.c
+++ b/media_player.c
@@ -4,7 +4,7 @@
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
- * $Id: media_player.c,v 1.52.2.7 2009-09-16 09:56:11 phintuka Exp $
+ * $Id: media_player.c,v 1.52.2.6 2008-12-10 23:00:18 phintuka Exp $
*
*/
@@ -46,7 +46,6 @@ class cXinelibPlayer : public cPlayer
cPlaylist m_Playlist;
bool m_Error;
- bool m_UseResumeFile;
int m_Speed;
void UpdateNumTracks(void);
@@ -76,7 +75,8 @@ class cXinelibPlayer : public cPlayer
bool NextFile(int step);
bool Playing(void) { return !(m_Error || cXinelibDevice::Instance().EndOfStreamReached()); }
bool Error(void) { return m_Error; }
- void UseResumeFile(bool Val) { m_UseResumeFile = Val; }
+
+ bool m_UseResume;
/* Playlist access */
cPlaylist& Playlist(void) { return m_Playlist; }
@@ -88,7 +88,7 @@ class cXinelibPlayer : public cPlayer
cXinelibPlayer::cXinelibPlayer(const char *File, bool Queue, const char *SubFile)
{
m_ResumeFile = NULL;
- m_UseResumeFile = true;
+ m_UseResume = true;
m_Error = false;
m_Speed = 1;
@@ -210,7 +210,7 @@ void cXinelibPlayer::UpdateNumTracks(void)
int count = cXinelibDevice::Instance().PlayFileCtrl("GETAUTOPLAYSIZE CD", 10000);
if(count>1) {
for(int i=0; i<count; i++)
- m_Playlist.Read(cString::sprintf("cdda:/%d", i+1));
+ m_Playlist.Read(cString::sprintf("cdda:/%d", i+1));
m_Playlist.Del(m_Playlist.First());
}
}
@@ -220,9 +220,9 @@ void cXinelibPlayer::Activate(bool On)
{
int pos = 0, len = 0, fd = -1;
if(On) {
- if(m_UseResumeFile && !*m_ResumeFile)
+ if(m_UseResume && !*m_ResumeFile)
m_ResumeFile = cString::sprintf("%s.resume", *m_File);
- if(m_UseResumeFile && 0 <= (fd = open(m_ResumeFile, O_RDONLY))) {
+ if(m_UseResume && 0 <= (fd = open(m_ResumeFile, O_RDONLY))) {
if(read(fd, &pos, sizeof(int)) != sizeof(int))
pos = 0;
close(fd);
@@ -232,10 +232,9 @@ void cXinelibPlayer::Activate(bool On)
// (those may contain #subtitle, #volnorm etc. directives)
cString mrl;
if(*m_SubFile)
- mrl = cString::sprintf("%s%s#subtitle:%s%s",
+ mrl = cString::sprintf("%s%s#subtitle:%s",
m_File[0] == '/' ? "file:" : "",
*cPlaylist::EscapeMrl(m_File),
- m_SubFile[0] == '/' ? "file:" : "",
*cPlaylist::EscapeMrl(m_SubFile));
else if((*m_File)[0] == '/')
mrl = cString::sprintf("%s%s",
@@ -244,7 +243,6 @@ void cXinelibPlayer::Activate(bool On)
else
mrl = cPlaylist::EscapeMrl(m_File);
- // Start replay
UpdateNumTracks();
m_Error = !cXinelibDevice::Instance().PlayFile(mrl, pos);
LOGDBG("cXinelibPlayer playing %s (%s)", *m_File, m_Error ? "FAIL" : "OK");
@@ -267,7 +265,7 @@ void cXinelibPlayer::Activate(bool On)
UpdateNumTracks();
}
} else {
- if(m_UseResumeFile && *m_ResumeFile) {
+ if(m_UseResume && *m_ResumeFile) {
pos = cXinelibDevice::Instance().PlayFileCtrl("GETPOS");
len = cXinelibDevice::Instance().PlayFileCtrl("GETLENGTH");
if(pos>10000 && pos < (len-10000)) {
@@ -286,7 +284,7 @@ void cXinelibPlayer::Activate(bool On)
}
m_ResumeFile = NULL;
}
- cXinelibDevice::Instance().PlayFile(NULL);
+ cXinelibDevice::Instance().PlayFile(NULL,0);
m_Error = false;
}
}
@@ -457,7 +455,7 @@ cXinelibPlayerControl::cXinelibPlayerControl(eMainMenuMode Mode, const char *Fil
number = 0;
lastTime.Set();
- m_Player->UseResumeFile( (Mode==ShowFiles) );
+ m_Player->m_UseResume = (Mode==ShowFiles);
MsgReplaying(*m_Player->Playlist().Current()->Title, *m_Player->File());
}
@@ -902,23 +900,21 @@ void cXinelibDvdPlayerControl::Show(void)
eOSState cXinelibDvdPlayerControl::ProcessKey(eKeys Key)
{
- // Check for end of stream and failed open
if ( !m_Player->Playing() ) {
LOGDBG("cXinelibDvdPlayerControl: EndOfStreamReached");
Hide();
return osEnd;
}
-
- // Update DVD title information
- const char *ti = cXinelibDevice::Instance().GetMetaInfo(miTitle);
- if (ti && ti[0] && (!m_CurrentDVDTitle || !strstr(m_CurrentDVDTitle, ti))) {
- memset(m_CurrentDVDTitle, 0, 63);
- strn0cpy(m_CurrentDVDTitle, ti, 63);
- m_Player->Playlist().Current()->Title = m_CurrentDVDTitle;
- MsgReplaying(m_CurrentDVDTitle, NULL);
+ else {
+ const char *ti = cXinelibDevice::Instance().GetMetaInfo(miTitle);
+ if (ti && ti[0] && (!m_CurrentDVDTitle || !strstr(m_CurrentDVDTitle, ti))) {
+ memset(m_CurrentDVDTitle, 0, 63);
+ strn0cpy(m_CurrentDVDTitle, ti, 63);
+ m_Player->Playlist().Current()->Title = m_CurrentDVDTitle;
+ MsgReplaying(m_CurrentDVDTitle, NULL);
+ }
}
- // Handle menu selection
if(Menu) {
if(Key == kRed)
Hide();
@@ -935,13 +931,10 @@ eOSState cXinelibDvdPlayerControl::ProcessKey(eKeys Key)
return osContinue;
}
- // Update progress bar display
if (m_DisplayReplay)
Show();
- // Handle menu navigation
-
- bool MenuDomain = !xc.dvd_arrow_keys_control_playback;
+ bool MenuDomain = false;
if(Key != kNone || m_DisplayReplay) {
const char *dt = cXinelibDevice::Instance().GetMetaInfo(miDvdTitleNo);
if(dt && !strcmp("0", dt))
@@ -969,8 +962,6 @@ eOSState cXinelibDvdPlayerControl::ProcessKey(eKeys Key)
}
}
- // Handle normal keys
-
if(!MenuDomain) {
switch(Key) {
// Replay control
@@ -1094,12 +1085,8 @@ eOSState cXinelibDvdPlayerControl::ProcessKey(eKeys Key)
class cXinelibImagePlayer : public cPlayer {
private:
- cString m_Mrl;
+ cString m_File;
bool m_Active;
- bool m_Error;
- cXinelibDevice *m_Dev;
-
- bool Play(void);
protected:
virtual void Activate(bool On);
@@ -1109,15 +1096,12 @@ class cXinelibImagePlayer : public cPlayer {
virtual ~cXinelibImagePlayer();
bool ShowImage(const char *File);
- bool Error(void) { return m_Error; }
};
cXinelibImagePlayer::cXinelibImagePlayer(const char *File)
{
- m_Mrl = File;
+ m_File = File;
m_Active = false;
- m_Error = false;
- m_Dev = &(cXinelibDevice::Instance());
}
cXinelibImagePlayer::~cXinelibImagePlayer()
@@ -1126,29 +1110,28 @@ cXinelibImagePlayer::~cXinelibImagePlayer()
Detach();
}
-bool cXinelibImagePlayer::Play(void)
-{
- if ((*m_Mrl)[0] == '/')
- m_Mrl = cString::sprintf("file:%s", *cPlaylist::EscapeMrl(m_Mrl));
-
- return m_Dev->PlayFile(m_Mrl, 0, true);
-}
-
void cXinelibImagePlayer::Activate(bool On)
{
- m_Active = On;
- m_Error = false;
- if (On)
- Play();
- else
- m_Dev->PlayFile(NULL);
+ if(On) {
+ m_Active = true;
+ cXinelibDevice::Instance().PlayFile( ( (*m_File)[0]=='/'
+ ? *cString::sprintf("file:%s", *cPlaylist::EscapeMrl(m_File))
+ : *m_File),
+ 0, true);
+ } else {
+ m_Active = false;
+ cXinelibDevice::Instance().PlayFile(NULL, 0);
+ }
}
bool cXinelibImagePlayer::ShowImage(const char *File)
{
- m_Mrl = File;
- if (m_Active)
- return Play();
+ m_File = File;
+ if(m_Active)
+ return cXinelibDevice::Instance().PlayFile( ( (*m_File)[0] == '/'
+ ? *cString::sprintf("file:%s", *cPlaylist::EscapeMrl(m_File))
+ : *m_File ),
+ 0, true);
return true;
}