From 3c65d4c0ffc4b7f09968dd269997ec5df32b3994 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Tue, 26 Mar 2013 18:45:17 +0400 Subject: [PATCH] gui/movieplayer.cpp: add position,duration, CTimeOSD class members; add UpdatePosition() to be called from infoviewer; set infoviewer timer to 1 sec for playback Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/6554921ad4bdc1896579d5414247046da2a9d1e3 Author: [CST] Focus Date: 2013-03-26 (Tue, 26 Mar 2013) ------------------ This commit was generated by Migit --- src/gui/movieplayer.cpp | 42 +++++++++++++++++++++++++++-------------- src/gui/movieplayer.h | 9 ++++++++- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index d12d66514..1250969a8 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -148,6 +148,8 @@ void CMoviePlayerGui::cutNeutrino() CNeutrinoApp::getInstance()->handleMsg(NeutrinoMessages::CHANGEMODE, NeutrinoMessages::mode_ts); m_LastMode = (CNeutrinoApp::getInstance()->getLastMode() | NeutrinoMessages::norezap); + /* set g_InfoViewer update timer to 1 sec, should be reset to default from restoreNeutrino->set neutrino mode */ + g_InfoViewer->setUpdateTimer(1000 * 1000); } void CMoviePlayerGui::restoreNeutrino() @@ -374,13 +376,13 @@ bool CMoviePlayerGui::SelectFile() if (cLine[strlen(cLine)-1]=='\r') cLine[strlen(cLine)-1]=0; - int duration; - sscanf(cLine, "#EXTINF:%d,%[^\n]\n", &duration, name); + int dur; + sscanf(cLine, "#EXTINF:%d,%[^\n]\n", &dur, name); if (strlen(cLine) > 0 && cLine[0]!='#') { char *url = strstr(cLine, "http://"); if (url != NULL) { - printf("name %s [%d] url: %s\n", name, duration, url); + printf("name %s [%d] url: %s\n", name, dur, url); full_name = url; if(strlen(name)) file_name = name; @@ -415,13 +417,13 @@ void CMoviePlayerGui::PlayFile(void) neutrino_msg_data_t data; menu_ret = menu_return::RETURN_REPAINT; - int position = 0, duration = 0; bool first_start_timeshift = false; bool time_forced = false; bool update_lcd = true; int eof = 0; - CTimeOSD FileTime; + //CTimeOSD FileTime; + position = 0, duration = 0; playstate = CMoviePlayerGui::STOPPED; printf("Startplay at %d seconds\n", startposition/1000); @@ -489,7 +491,7 @@ void CMoviePlayerGui::PlayFile(void) updateLcd(); } if (first_start_timeshift) { - callInfoViewer(duration, position); + callInfoViewer(/*duration, position*/); first_start_timeshift = false; } @@ -539,7 +541,7 @@ void CMoviePlayerGui::PlayFile(void) //update_lcd = true; updateLcd(); if (!timeshift) - callInfoViewer(duration, position); + callInfoViewer(/*duration, position*/); } if (time_forced) { time_forced = false; @@ -560,7 +562,7 @@ void CMoviePlayerGui::PlayFile(void) //update_lcd = true; updateLcd(); if (!timeshift) - callInfoViewer(duration, position); + callInfoViewer(/*duration, position*/); } else if (msg == (neutrino_msg_t) g_settings.mpkey_bookmark) { handleMovieBrowser((neutrino_msg_t) g_settings.mpkey_bookmark, position); @@ -591,7 +593,7 @@ void CMoviePlayerGui::PlayFile(void) //update_lcd = true; if (!timeshift) - callInfoViewer(duration, position); + callInfoViewer(/*duration, position*/); if (!FileTime.IsVisible()) { FileTime.show(position); @@ -622,7 +624,7 @@ void CMoviePlayerGui::PlayFile(void) } else if (msg == CRCInput::RC_0) { // cancel bookmark jump handleMovieBrowser(CRCInput::RC_0, position); } else if (msg == CRCInput::RC_help || msg == CRCInput::RC_info) { - callInfoViewer(duration, position); + callInfoViewer(/*duration, position*/); update_lcd = true; //showHelpTS(); } else if(timeshift && (msg == CRCInput::RC_text || msg == CRCInput::RC_epg || msg == NeutrinoMessages::SHOW_EPG)) { @@ -719,7 +721,7 @@ void CMoviePlayerGui::PlayFile(void) InfoClock->StartClock(); } -void CMoviePlayerGui::callInfoViewer(const int duration, const int curr_pos) +void CMoviePlayerGui::callInfoViewer(/*const int duration, const int curr_pos*/) { if(timeshift) { g_InfoViewer->showTitle(CNeutrinoApp::getInstance()->channelList->getActiveChannelNumber(), @@ -733,12 +735,12 @@ void CMoviePlayerGui::callInfoViewer(const int duration, const int curr_pos) if (isMovieBrowser && p_movie_info) { g_InfoViewer->showMovieTitle(playstate, p_movie_info->epgChannel, p_movie_info->epgTitle, p_movie_info->epgInfo1, - duration, curr_pos); + duration, position); return; } /* not moviebrowser => use the filename as title */ - g_InfoViewer->showMovieTitle(playstate, file_name, "", "", duration, curr_pos); + g_InfoViewer->showMovieTitle(playstate, file_name, "", "", duration, position); } bool CMoviePlayerGui::getAudioName(int apid, std::string &apidtitle) @@ -896,7 +898,7 @@ void CMoviePlayerGui::selectAudioPid(bool file_player) } } -void CMoviePlayerGui::handleMovieBrowser(neutrino_msg_t msg, int position) +void CMoviePlayerGui::handleMovieBrowser(neutrino_msg_t msg, int /*position*/) { CMovieInfo cMovieInfo; // funktions to save and load movie info @@ -1150,6 +1152,18 @@ void CMoviePlayerGui::handleMovieBrowser(neutrino_msg_t msg, int position) return; } +void CMoviePlayerGui::UpdatePosition() +{ + if(playback->GetPosition(position, duration)) { + if(duration > 100) + file_prozent = (unsigned char) (position / (duration / 100)); + FileTime.update(position, duration); +#ifdef DEBUG + printf("CMoviePlayerGui::PlayFile: speed %d position %d duration %d (%d, %d%%)\n", speed, position, duration, duration-position, file_prozent); +#endif + } +} + void CMoviePlayerGui::showHelpTS() { Helpbox helpbox; diff --git a/src/gui/movieplayer.h b/src/gui/movieplayer.h index 92f1af5e9..df8434f67 100644 --- a/src/gui/movieplayer.h +++ b/src/gui/movieplayer.h @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -74,6 +75,9 @@ class CMoviePlayerGui : public CMenuTarget CMoviePlayerGui::state playstate; int speed; int startposition; + int position; + int duration; + CTimeOSD FileTime; unsigned short numpida; unsigned short vpid; @@ -109,7 +113,7 @@ class CMoviePlayerGui : public CMenuTarget void restoreNeutrino(); void showHelpTS(void); - void callInfoViewer(const int duration, const int pos); + void callInfoViewer(/*const int duration, const int pos*/); void fillPids(); bool getAudioName(int pid, std::string &apidtitle); void selectAudioPid(bool file_player); @@ -132,6 +136,9 @@ class CMoviePlayerGui : public CMenuTarget bool Playing() { return playing; }; std::string CurrentAudioName() { return currentaudioname; }; int GetSpeed() { return speed; } + int GetPosition() { return position; } + int GetDuration() { return duration; } + void UpdatePosition(); int timeshift; int file_prozent; };