From 8035264d471f75407222a48f2fa707795e25d461 Mon Sep 17 00:00:00 2001 From: Dennis Bendlin <> Date: Thu, 5 Sep 2013 12:03:09 +0200 Subject: Add replay info. --- ChangeLog | 7 +++++- play.cpp | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++---------- player.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- player.h | 14 +++++++++++- 4 files changed, 146 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 877c65f..611d60c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ +User Dennis Bendlin +Date: Thu Sep 5 12:02:29 CEST 2013 + + Add replay info. + User johns -Date: +Date: Mon Aug 26 10:12:45 CEST 2013 Allow filenames starting with '-'. Add dia show image/picture viewer. diff --git a/play.cpp b/play.cpp index 70702ee..269426d 100644 --- a/play.cpp +++ b/play.cpp @@ -3,7 +3,7 @@ /// /// Copyright (c) 2012, 2013 by Johns. All Rights Reserved. /// -/// Contributor(s): +/// Contributor(s): Dennis Bendlin /// /// License: AGPLv3 /// @@ -263,7 +263,11 @@ bool cMyPlayer::GetReplayMode(bool & play, bool & forward, int &speed) { play = !PlayerPaused; forward = true; - speed = play ? PlayerSpeed : -1; + if (PlayerSpeed == 1) { + speed = -1; + } else { + speed = PlayerSpeed; + } return true; } @@ -332,6 +336,8 @@ class cMyControl:public cControl void ShowProgress(void); ///< display progress bar virtual void Show(void); ///< show replay control virtual void Hide(void); ///< hide replay control + bool infoVisible; ///< RecordingInfo visible + time_t timeoutShow; ///< timeout shown control public: cMyControl(const char *); ///< player control constructor @@ -373,7 +379,38 @@ void cMyControl::ShowReplayMode(void) */ void cMyControl::ShowProgress(void) { - // FIXME: + if (Display || (!cOsd::IsOpen())) { + bool play; + bool forward; + int speed; + + if (GetReplayMode(play, forward, speed)) { + if (!Display) { + Display = Skins.Current()->DisplayReplay(false); + } + + if (!infoVisible) { + infoVisible = true; + timeoutShow = time(0) + Setup.ChannelInfoTime; + PlayerGetLength(); + PlayerGetMetaTitle(); + PlayerGetFilename(); + } + + PlayerGetCurrentPosition(); + if (strcmp(PlayerTitle, "") != 0) { + Display->SetTitle(PlayerTitle); + } else { + Display->SetTitle(PlayerFilename); + } + Display->SetProgress(PlayerCurrent, PlayerTotal); + Display->SetMode(play, forward, speed); + Display->SetCurrent(IndexToHMSF(PlayerCurrent, false, 1)); + Display->SetTotal(IndexToHMSF(PlayerTotal, false, 1)); + } + SetNeedsFastResponse(true); + Skins.Flush(); + } } /** @@ -382,9 +419,10 @@ void cMyControl::ShowProgress(void) void cMyControl::Show(void) { dsyslog("[play]%s:\n", __FUNCTION__); - if (!Display) { + if (Setup.ShowReplayMode) + ShowReplayMode(); + else ShowProgress(); - } } /** @@ -397,6 +435,7 @@ cMyControl::cMyControl(const char *filename) { Display = NULL; Status = new cMyStatus; // start monitoring volume + infoVisible = false; //LastSkipKey = kNone; //LastSkipSeconds = REPLAYCONTROLSKIPSECONDS; @@ -458,6 +497,15 @@ eOSState cMyControl::ProcessKey(eKeys key) cControl::Shutdown(); return osEnd; } + + if (infoVisible) { // if RecordingInfo visible then update + if (timeoutShow && time(0) > timeoutShow) { + Hide(); + timeoutShow = 0; + infoVisible = false; + } else + ShowProgress(); + } //state=cOsdMenu::ProcessKey(key); state = osContinue; switch ((int)key) { // cast to shutup g++ warnings @@ -475,7 +523,7 @@ eOSState cMyControl::ProcessKey(eKeys key) PlayerSendPause(); PlayerPaused ^= 1; } - ShowReplayMode(); + Show(); break; case kDown: @@ -486,7 +534,7 @@ eOSState cMyControl::ProcessKey(eKeys key) case kPause: PlayerSendPause(); PlayerPaused ^= 1; - ShowReplayMode(); + Show(); break; case kFastRew | k_Release: @@ -507,7 +555,7 @@ eOSState cMyControl::ProcessKey(eKeys key) } else { PlayerSendSeek(-10); } - ShowReplayMode(); + Show(); break; case kRight: if (PlayerDvdNav) { @@ -518,7 +566,7 @@ eOSState cMyControl::ProcessKey(eKeys key) if (PlayerSpeed < 32) { PlayerSendSetSpeed(PlayerSpeed *= 2); } - ShowReplayMode(); + Show(); break; case kRed: @@ -583,8 +631,11 @@ eOSState cMyControl::ProcessKey(eKeys key) // FIXME: PlayerDvdNav = 0; break; } - // FIXME: full mode - ShowReplayMode(); + if (infoVisible) { + Hide(); + infoVisible = false; + } else + Show(); break; case kBack: diff --git a/player.c b/player.c index c74841e..23f35b1 100644 --- a/player.c +++ b/player.c @@ -3,7 +3,7 @@ /// /// Copyright (c) 2012, 2013 by Johns. All Rights Reserved. /// -/// Contributor(s): +/// Contributor(s): Dennis Bendlin /// /// License: AGPLv3 /// @@ -136,6 +136,10 @@ static int PlayerVolume = -1; ///< volume 0 - 100 char PlayerDvdNav; ///< dvdnav active char PlayerPaused; ///< player paused char PlayerSpeed; ///< player playback speed +int PlayerCurrent; ///< current postion in seconds +int PlayerTotal; ///< total length in seconds +char PlayerTitle[256]; ///< title from meta data +char PlayerFilename[256]; ///< filename ////////////////////////////////////////////////////////////////////////////// // Slave @@ -150,6 +154,7 @@ char PlayerSpeed; ///< player playback speed static void PlayerParseLine(const char *data, int size) { Debug(4, "play/parse: |%.*s|\n", size, data); + (void)size; // data is \0 terminated if (!strncasecmp(data, "DVDNAV_TITLE_IS_MENU", 20)) { @@ -172,6 +177,24 @@ static void PlayerParseLine(const char *data, int size) if (sscanf(data, "ID_SID_%d_LANG=%s", &sid, lang) == 2) { Debug(3, "SID(%d) = %s\n", sid, lang); } + } else if (!strncasecmp(data, "ANS_META_TITLE=", 14)) { + if (sscanf(data, "ANS_META_TITLE='%[^\t\n]", PlayerTitle) == 1) { + PlayerTitle[strlen(PlayerTitle) - 1] = 0; + Debug(3, "PlayerTitle= %s\n", PlayerTitle); + } + } else if (!strncasecmp(data, "ANS_FILENAME=", 12)) { + if (sscanf(data, "ANS_FILENAME='%[^\t\n]", PlayerFilename) == 1) { + PlayerFilename[strlen(PlayerFilename) - 1] = 0; + Debug(3, "PlayerFilename= %s\n", PlayerFilename); + } + } else if (!strncasecmp(data, "ANS_LENGTH=", 10)) { + if (sscanf(data, "ANS_LENGTH=%d", &PlayerTotal) == 1) { + Debug(3, "PlayerTotal=%d\n", PlayerTotal); + } + } else if (!strncasecmp(data, "ANS_TIME_POSITION=", 17)) { + if (sscanf(data, "ANS_TIME_POSITION=%d", &PlayerCurrent) == 1) { + Debug(3, "PlayerCurrent=%d\n", PlayerCurrent); + } } } @@ -270,7 +293,7 @@ static void PlayerExec(const char *filename) #ifdef DEBUG args[3] = "all=6:global=4:cplayer=4:identify=4"; #else - args[3] = "all=2:global=2:cplayer=2:identify=4"; + args[3] = "all=2:global=4:cplayer=2:identify=4"; #endif if (ConfigOsdOverlay) { args[4] = "-noontop"; @@ -694,6 +717,46 @@ void PlayerSendDvdNavMenu(void) } } +/** +** Get length in seconds. +*/ +void PlayerGetLength(void) +{ + if (ConfigUseSlave) { + SendCommand("get_time_length\n"); + } +} + +/** +** Get current position in seconds. +*/ +void PlayerGetCurrentPosition(void) +{ + if (ConfigUseSlave) { + SendCommand("get_time_pos\n"); + } +} + +/** +** Get title from meta data. +*/ +void PlayerGetMetaTitle(void) +{ + if (ConfigUseSlave) { + SendCommand("get_meta_title\n"); + } +} + +/** +** Get filename. +*/ +void PlayerGetFilename(void) +{ + if (ConfigUseSlave) { + SendCommand("get_file_name\n"); + } +} + /** ** Start external player. ** diff --git a/player.h b/player.h index 519ca62..0c86be2 100644 --- a/player.h +++ b/player.h @@ -3,7 +3,7 @@ /// /// Copyright (c) 2012, 2013 by Johns. All Rights Reserved. /// -/// Contributor(s): +/// Contributor(s): Dennis Bendlin /// /// License: AGPLv3 /// @@ -105,6 +105,10 @@ extern "C" extern char PlayerDvdNav; ///< dvdnav active extern char PlayerPaused; ///< player paused extern char PlayerSpeed; ///< player playback speed + extern int PlayerCurrent; ///< current postion in seconds + extern int PlayerTotal; ///< total length in seconds + extern char PlayerTitle[256]; ///< title from meta data + extern char PlayerFilename[256]; ///< filename /// Start external player extern void PlayerStart(const char *name); @@ -142,6 +146,14 @@ extern "C" extern void PlayerSendDvdNavPrev(void); /// Player send dvd-nav prev extern void PlayerSendDvdNavMenu(void); + /// Get length in seconds. + extern void PlayerGetLength(void); + /// Get current position in seconds. + extern void PlayerGetCurrentPosition(void); + /// Get title from meta data. + extern void PlayerGetMetaTitle(void); + /// Get filename. + extern void PlayerGetFilename(void); #ifdef __cplusplus } -- cgit v1.2.3