From fb2967ca8bc27be2428801c3153a822d5406bfec Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Wed, 3 Feb 2016 16:27:07 +0100 Subject: [PATCH] - movieplayer: add virtual zap mode for moviebrowser playlists This commit fixes virtual zap for timeshift mode too. TODO: virtual zap for fileplayer playlists --- data/locale/deutsch.locale | 4 +- data/locale/english.locale | 4 +- src/gui/infoviewer.cpp | 31 ++++++-- src/gui/movieplayer.cpp | 143 ++++++++++++++++++++++++++++++------- src/gui/movieplayer.h | 7 +- 5 files changed, 153 insertions(+), 36 deletions(-) diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index dddb197b9..109271a93 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -809,7 +809,7 @@ keybindingmenu.head Tasten-Belegungen bearbeiten keybindingmenu.lastchannel Letzter Kanal keybindingmenu.longkeypress_duration Langer Tastendruck keybindingmenu.misc Sonstige -keybindingmenu.mode_left_right_key_tv Funktion li/re Tasten im TV-Modus +keybindingmenu.mode_left_right_key_tv Funktion der li/re-Tasten keybindingmenu.mode_left_right_key_tv_infobar Infobar einblenden keybindingmenu.mode_left_right_key_tv_volume Lautstärkeregelung keybindingmenu.mode_left_right_key_tv_vzap Virtual Zap @@ -1107,7 +1107,7 @@ menu.hint_key_quickzap Konfigurieren Sie die Tastenbelegung für die Schnellumsc menu.hint_key_record Konfigurieren Sie die Taste für den Aufnahmestart menu.hint_key_repeatblock Die Verzögerung nach einem Tastendruck bis die Box reagieren soll menu.hint_key_repeatblockgeneric Die Verzögerung zwischen den Tastewiederholungen bis die Box reagieren soll -menu.hint_key_right Wählen Sie die Funktion für die Tasten 'links' und 'rechts' im TV/Radio-Modus +menu.hint_key_right Wählen Sie die Funktion für die Tasten 'links' und 'rechts' im TV/Radio- und Movieplayer-Modus menu.hint_key_save Speichern Sie Ihre Tastenbelegungen in einer Datei ab menu.hint_key_screenshot Weisen Sie eine Taste zu, um Menü- und/oder TV-Screenshots zu speichern menu.hint_key_sort Weisen Sie eine Taste für das Sortieren in der Kanalliste zu diff --git a/data/locale/english.locale b/data/locale/english.locale index 96593f610..025a06954 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -809,7 +809,7 @@ keybindingmenu.head Edit Keybindings keybindingmenu.lastchannel Quick Zap keybindingmenu.longkeypress_duration Long key-press keybindingmenu.misc Misc -keybindingmenu.mode_left_right_key_tv Left/Right Key Behavior in TV-Mode +keybindingmenu.mode_left_right_key_tv Left/Right key behaviour keybindingmenu.mode_left_right_key_tv_infobar Show Infobar keybindingmenu.mode_left_right_key_tv_volume Volume Control keybindingmenu.mode_left_right_key_tv_vzap Virtual Zap @@ -1107,7 +1107,7 @@ menu.hint_key_quickzap Configure keybingdings for quick\nchannel switch menu.hint_key_record Assign button to start a recording menu.hint_key_repeatblock Delay after button press and before\nfirst key repeat menu.hint_key_repeatblockgeneric Delay between key repeats\nwhile button pressed -menu.hint_key_right Select 'right' function in live TV/Radio mode +menu.hint_key_right Select function for 'left' and 'right' keys in live TV/Radio mode and movieplayer mode menu.hint_key_save Save keybindings to file menu.hint_key_screenshot Assign button to save GUI and/or TV screenshot menu.hint_key_sort Assign button to change channel list sort order diff --git a/src/gui/infoviewer.cpp b/src/gui/infoviewer.cpp index 091c50cf1..63937040e 100644 --- a/src/gui/infoviewer.cpp +++ b/src/gui/infoviewer.cpp @@ -940,18 +940,41 @@ void CInfoViewer::loop(bool show_dot) } else if (msg == CRCInput::RC_sat || msg == CRCInput::RC_favorites) { g_RCInput->postMsg (msg, 0); res = messages_return::cancel_info; - } - else if (msg == CRCInput::RC_help || msg == CRCInput::RC_info) { + } else if (msg == CRCInput::RC_help || msg == CRCInput::RC_info) { g_RCInput->postMsg (NeutrinoMessages::SHOW_EPG, 0); res = messages_return::cancel_info; } else if ((msg == NeutrinoMessages::EVT_TIMER) && (data == fader.GetFadeTimer())) { if(fader.FadeDone()) res = messages_return::cancel_info; } else if ((msg == CRCInput::RC_ok) || (msg == CRCInput::RC_home) || (msg == CRCInput::RC_timeout)) { + if ((g_settings.mode_left_right_key_tv == SNeutrinoSettings::VZAP) && (msg == CRCInput::RC_ok)) + { + if (fileplay) + { + // in movieplayer mode process vzap keys in movieplayer.cpp + //printf("%s:%d: imitate VZAP; RC_ok\n", __func__, __LINE__); + CMoviePlayerGui::getInstance().setFromInfoviewer(true); + g_RCInput->postMsg (msg, data); + hideIt = true; + } + } if(fader.StartFadeOut()) timeoutEnd = CRCInput::calcTimeoutEnd (1); else res = messages_return::cancel_info; + } else if ((g_settings.mode_left_right_key_tv == SNeutrinoSettings::VZAP) && ((msg == CRCInput::RC_right) || (msg == CRCInput::RC_left ))) { + if (fileplay) + { + // in movieplayer mode process vzap keys in movieplayer.cpp + //printf("%s:%d: imitate VZAP; RC_left/right\n", __func__, __LINE__); + CMoviePlayerGui::getInstance().setFromInfoviewer(true); + g_RCInput->postMsg (msg, data); + hideIt = true; + } + else + setSwitchMode(IV_MODE_VIRTUAL_ZAP); + res = messages_return::cancel_all; + hideIt = true; } else if ((msg == NeutrinoMessages::EVT_TIMER) && (data == sec_timer_id)) { showSNR (); if (timeset) @@ -986,10 +1009,6 @@ void CInfoViewer::loop(bool show_dot) g_RCInput->postMsg (msg, data); res = messages_return::cancel_info; - } else if ((g_settings.mode_left_right_key_tv == SNeutrinoSettings::VZAP) && ((msg == CRCInput::RC_right) || (msg == CRCInput::RC_left ))) { - setSwitchMode(IV_MODE_VIRTUAL_ZAP); - res = messages_return::cancel_all; - hideIt = true; } else if (msg == NeutrinoMessages::EVT_TIMESET) { /* handle timeset event in upper layer, ignore here */ res = neutrino->handleMsg (msg, data); diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index 3b88cd4d1..d271feab5 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -74,6 +75,7 @@ extern cVideo * videoDecoder; extern CRemoteControl *g_RemoteControl; /* neutrino.cpp */ extern CInfoClock *InfoClock; +extern CVolume* g_volume; #define TIMESHIFT_SECONDS 3 #define ISO_MOUNT_POINT "/media/iso" @@ -189,6 +191,8 @@ void CMoviePlayerGui::Init(void) info_1 = ""; info_2 = ""; filelist_it = filelist.end(); + vzap_it = filelist_it; + fromInfoviewer = false; keyPressed = CMoviePlayerGui::PLUGIN_PLAYSTATE_NORMAL; isLuaPlay = false; haveLuaInfoFunc = false; @@ -901,6 +905,55 @@ bool CMoviePlayerGui::SetPosition(int pos, bool absolute) return res; } +void CMoviePlayerGui::quickZap(neutrino_msg_t msg) +{ + if ((msg == CRCInput::RC_right) || msg == (neutrino_msg_t) g_settings.key_quickzap_up) + { + //printf("CMoviePlayerGui::%s: CRCInput::RC_right or g_settings.key_quickzap_up\n", __func__); + if (isLuaPlay) + { + playstate = CMoviePlayerGui::STOPPED; + keyPressed = CMoviePlayerGui::PLUGIN_PLAYSTATE_NEXT; + ClearQueue(); + } + else if (!filelist.empty()) + { + if (filelist_it < (filelist.end() - 1)) + { + playstate = CMoviePlayerGui::STOPPED; + ++filelist_it; + } + else if (repeat_mode == REPEAT_ALL) + { + playstate = CMoviePlayerGui::STOPPED; + ++filelist_it; + if (filelist_it == filelist.end()) + { + filelist_it = filelist.begin(); + } + } + } + } + else if ((msg == CRCInput::RC_left) || msg == (neutrino_msg_t) g_settings.key_quickzap_down) + { + //printf("CMoviePlayerGui::%s: CRCInput::RC_left or g_settings.key_quickzap_down\n", __func__); + if (isLuaPlay) + { + playstate = CMoviePlayerGui::STOPPED; + keyPressed = CMoviePlayerGui::PLUGIN_PLAYSTATE_PREV; + ClearQueue(); + } + else if (filelist.size() > 1) + { + if (filelist_it != filelist.begin()) + { + playstate = CMoviePlayerGui::STOPPED; + --filelist_it; + } + } + } +} + void CMoviePlayerGui::PlayFileLoop(void) { bool first_start = true; @@ -993,29 +1046,36 @@ void CMoviePlayerGui::PlayFileLoop(void) playstate = CMoviePlayerGui::STOPPED; keyPressed = CMoviePlayerGui::PLUGIN_PLAYSTATE_STOP; ClearQueue(); - } else if (isLuaPlay && (msg == (neutrino_msg_t) CRCInput::RC_right)) { - playstate = CMoviePlayerGui::STOPPED; - keyPressed = CMoviePlayerGui::PLUGIN_PLAYSTATE_NEXT; - ClearQueue(); - } else if (isLuaPlay && (msg == (neutrino_msg_t) CRCInput::RC_left)) { - playstate = CMoviePlayerGui::STOPPED; - keyPressed = CMoviePlayerGui::PLUGIN_PLAYSTATE_PREV; - ClearQueue(); - } else if ((!filelist.empty() && msg == (neutrino_msg_t) CRCInput::RC_right)) { - if (filelist_it < (filelist.end() - 1)) { - ++filelist_it; - playstate = CMoviePlayerGui::STOPPED; - } else if (repeat_mode == REPEAT_ALL) { - ++filelist_it; - if (filelist_it == filelist.end()) - filelist_it = filelist.begin(); - playstate = CMoviePlayerGui::STOPPED; - } - } else if (filelist.size() > 1 && msg == (neutrino_msg_t) CRCInput::RC_left) { - if (filelist_it != filelist.begin()) { - playstate = CMoviePlayerGui::STOPPED; - --filelist_it; + } else if (msg == CRCInput::RC_left || msg == CRCInput::RC_right) { + bool reset_vzap_it = true; + switch (g_settings.mode_left_right_key_tv) + { + case SNeutrinoSettings::INFOBAR: + callInfoViewer(); + break; + case SNeutrinoSettings::VZAP: + if (fromInfoviewer) + { + set_vzap_it(msg == CRCInput::RC_right); + reset_vzap_it = false; + fromInfoviewer = false; + } + callInfoViewer(reset_vzap_it); + break; + case SNeutrinoSettings::VOLUME: + g_volume->setVolume(msg); + break; + default: /* SNeutrinoSettings::ZAP */ + quickZap(msg); + break; } + } else if (msg == (neutrino_msg_t) g_settings.key_quickzap_up || msg == (neutrino_msg_t) g_settings.key_quickzap_down) { + quickZap(msg); + } else if (fromInfoviewer && msg == CRCInput::RC_ok && !filelist.empty()) { + printf("CMoviePlayerGui::%s: start playlist movie #%d\n", __func__, vzap_it - filelist.begin()); + fromInfoviewer = false; + playstate = CMoviePlayerGui::STOPPED; + filelist_it = vzap_it; } else if (timeshift == TSHIFT_MODE_OFF && !isWebTV /* && !isYT */ && (msg == (neutrino_msg_t) g_settings.mpkey_next_repeat_mode)) { repeat_mode = (repeat_mode_enum)((int)repeat_mode + 1); if (repeat_mode > (int) REPEAT_ALL) @@ -1282,15 +1342,48 @@ void CMoviePlayerGui::PlayFileEnd(bool restore) } } -void CMoviePlayerGui::callInfoViewer() +void CMoviePlayerGui::set_vzap_it(bool up) { + //printf("CMoviePlayerGui::%s: vzap_it: %d count %s\n", __func__, vzap_it - filelist.begin(), up ? "up" : "down"); + if (up) + { + if (vzap_it < (filelist.end() - 1)) + ++vzap_it; + } + else + { + if (vzap_it > filelist.begin()) + --vzap_it; + } + //printf("CMoviePlayerGui::%s: vzap_it: %d\n", __func__, vzap_it - filelist.begin()); +} + +void CMoviePlayerGui::callInfoViewer(bool init_vzap_it) +{ + if (init_vzap_it) + { + //printf("CMoviePlayerGui::%s: init_vzap_it\n", __func__); + vzap_it = filelist_it; + } + if (timeshift != TSHIFT_MODE_OFF) { g_InfoViewer->showTitle(CNeutrinoApp::getInstance()->channelList->getActiveChannel()); return; } - if (isMovieBrowser && p_movie_info) { - g_InfoViewer->showMovieTitle(playstate, p_movie_info->epgEpgId >>16, p_movie_info->epgChannel, p_movie_info->epgTitle, p_movie_info->epgInfo1, + if (isMovieBrowser && p_movie_info) + { + MI_MOVIE_INFO *mi; + mi = p_movie_info; + if (!filelist.empty() && g_settings.mode_left_right_key_tv == SNeutrinoSettings::VZAP) + { + if (vzap_it <= filelist.end()) { + unsigned idx = vzap_it - filelist.begin(); + //printf("CMoviePlayerGui::%s: idx: %d\n", __func__, idx); + mi = milist[idx]; + } + } + g_InfoViewer->showMovieTitle(playstate, mi->epgEpgId >>16, mi->epgChannel, mi->epgTitle, mi->epgInfo1, duration, position, repeat_mode); return; } diff --git a/src/gui/movieplayer.h b/src/gui/movieplayer.h index aa558cc24..53621ab9d 100644 --- a/src/gui/movieplayer.h +++ b/src/gui/movieplayer.h @@ -153,6 +153,9 @@ class CMoviePlayerGui : public CMenuTarget CFileFilter tsfilefilter; CFileList filelist; CFileList::iterator filelist_it; + CFileList::iterator vzap_it; + void set_vzap_it(bool up); + bool fromInfoviewer; std::string Path_local; int menu_ret; bool autoshot_done; @@ -177,8 +180,9 @@ class CMoviePlayerGui : public CMenuTarget void PlayFileEnd(bool restore = true); void cutNeutrino(); + void quickZap(neutrino_msg_t msg); void showHelpTS(void); - void callInfoViewer(); + void callInfoViewer(bool init_vzap_it = true); void fillPids(); bool getAudioName(int pid, std::string &apidtitle); void getCurrentAudioName( bool file_player, std::string &audioname); @@ -236,6 +240,7 @@ class CMoviePlayerGui : public CMenuTarget size_t GetReadCount(); std::string GetFile() { return pretty_name; } void restoreNeutrino(); + void setFromInfoviewer(bool f) { fromInfoviewer = f; }; void setBlockedFromPlugin(bool b) { blockedFromPlugin = b; }; bool getBlockedFromPlugin() { return blockedFromPlugin; }; void setLuaInfoFunc(lua_State* L, bool func) { luaState = L; haveLuaInfoFunc = func; };