From 5705809f1ade6483ef3628cebf64fa0dcbef294d Mon Sep 17 00:00:00 2001 From: vanhofen Date: Sat, 13 May 2017 17:45:59 +0200 Subject: [PATCH] movieplayer: allow bisectional jumps with RC_page_up/down based upon code by TangoCash Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/ca218e5390ed2471eeb6ef89e8c097786065271c Author: vanhofen Date: 2017-05-13 (Sat, 13 May 2017) Origin message was: ------------------ - movieplayer: allow bisectional jumps with RC_page_up/down based upon code by TangoCash ------------------ This commit was generated by Migit --- data/locale/deutsch.locale | 2 ++ data/locale/english.locale | 2 ++ src/gui/keybind_setup.cpp | 7 +++++++ src/gui/movieplayer.cpp | 34 ++++++++++++++++++++++++++++++++++ src/neutrino.cpp | 2 ++ src/system/locals.h | 2 ++ src/system/locals_intern.h | 2 ++ src/system/settings.h | 1 + 8 files changed, 52 insertions(+) diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 2c4d31792..250e388da 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -1352,6 +1352,7 @@ menu.hint_misc_zapit Verwaltung der Start-Kanäle für den TV/Radio-Modus menu.hint_movie Wiedergabe von Filmen menu.hint_moviebrowser_fonts Ändern Sie die Schriftgrößen im Moviebrowser (Meine Aufnahmen) menu.hint_moviebrowser_setup Legen Sie Auswahl- und Anzeigeoptionen des MovieBrowsers fest +menu.hint_movieplayer_bisection_jump Für das Vor- und Zurückspringen mit Seite hoch/runter wird ein bisektionaler Modus verwendet menu.hint_movieplayer_plugin Wählen Sie ein Plugin, das mit einer Schnellstart-Taste im Movieplayer-Modus gestartet wird menu.hint_net_broadcast Ändern Sie die Broadcast-Adresse.\nWenn Sie unsicher sind, verwenden Sie zuletzt .255 menu.hint_net_dhcp Verwenden Sie einen DHCP-Server für die automatische Vergabe einer IP-Adresse im Netzwerk @@ -1999,6 +2000,7 @@ moviebrowser.yt_region Region moviebrowser.yt_related Passende Videos moviebrowser.yt_search Suche nach Stichwort moviecut.cancel Bearbeiten des Filmes abbrechen? +movieplayer.bisection_jump Bisektionale Sprünge movieplayer.bookmark Bookmarks movieplayer.bookmarkname Bookmark Name movieplayer.bookmarkname_hint1 Geben Sie den Namen für das neue Lesezeichen ein diff --git a/data/locale/english.locale b/data/locale/english.locale index acdba6ab8..f2848a9a0 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -1352,6 +1352,7 @@ menu.hint_misc_zapit Initial TV/Radio channels menu.hint_movie Play movies menu.hint_moviebrowser_fonts Change moviebrowser (My recordings) font sizes menu.hint_moviebrowser_setup Set selection and display options. +menu.hint_movieplayer_bisection_jump Use bisectional mode to jump forward/backward with page up/down menu.hint_movieplayer_plugin Choose a plugin that's executed with the one touch key in movieplayer mode menu.hint_net_broadcast Enter broadcast address\nif unsure, use IP address with last .255 menu.hint_net_dhcp Use DHCP server to auto-configure @@ -1999,6 +2000,7 @@ moviebrowser.yt_region Region moviebrowser.yt_related Related videos moviebrowser.yt_search Search keyword moviecut.cancel Cancel movie editing? +movieplayer.bisection_jump Bisectional jumps movieplayer.bookmark Bookmarks movieplayer.bookmarkname Bookmarkname movieplayer.bookmarkname_hint1 Enter a name for your new bookmark diff --git a/src/gui/keybind_setup.cpp b/src/gui/keybind_setup.cpp index bd6af76e7..4027eebe5 100644 --- a/src/gui/keybind_setup.cpp +++ b/src/gui/keybind_setup.cpp @@ -512,6 +512,13 @@ void CKeybindSetup::showKeyBindMovieplayerSetup(CMenuWidget *bindSettings_mplaye mf->setHint("", key_settings[i].hint); bindSettings_mplayer->addItem(mf); } + + bindSettings_mplayer->addItem(GenericMenuSeparatorLine); //NI + + //NI - bisectional jumps + CMenuOptionChooser * mc = new CMenuOptionChooser(LOCALE_MOVIEPLAYER_BISECTION_JUMP, &g_settings.movieplayer_bisection_jump, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true); + mc->setHint("", LOCALE_MENU_HINT_MOVIEPLAYER_BISECTION_JUMP); + bindSettings_mplayer->addItem(mc); } void CKeybindSetup::showKeyBindMoviebrowserSetup(CMenuWidget *bindSettings_mbrowser) diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index bed0d13ec..7f806bdaa 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -1350,6 +1350,11 @@ void CMoviePlayerGui::PlayFileLoop(void) int position_tmp = 0; bool at_eof = !(playstate >= CMoviePlayerGui::PLAY);; keyPressed = CMoviePlayerGui::PLUGIN_PLAYSTATE_NORMAL; + neutrino_msg_t lastmsg = 0; //NI + + //NI - bisectional jumps + int bisection_jump = 300; + int bisection_loop = -1; while (playstate >= CMoviePlayerGui::PLAY) { @@ -1366,6 +1371,12 @@ void CMoviePlayerGui::PlayFileLoop(void) neutrino_msg_data_t data; g_RCInput->getMsg(&msg, &data, 10); // 1 secs.. + //NI - bisectional jumps + if (bisection_loop > -1) + bisection_loop++; + if (bisection_loop > 10) + bisection_loop = -1; + if ((playstate >= CMoviePlayerGui::PLAY) && (timeshift != TSHIFT_MODE_OFF || (playstate != CMoviePlayerGui::PAUSE))) { if (playback->GetPosition(position, duration)) { FileTimeOSD->update(position, duration); @@ -1610,10 +1621,30 @@ void CMoviePlayerGui::PlayFileLoop(void) SetPosition(duration/2, true); } else if (msg == CRCInput::RC_8) { // goto end SetPosition(duration - 60 * 1000, true); +//NI +#if 0 } else if (msg == CRCInput::RC_page_up) { SetPosition(10 * 1000); } else if (msg == CRCInput::RC_page_down) { SetPosition(-10 * 1000); +#endif + //NI - bisectional jumps + } else if (msg == CRCInput::RC_page_up || msg == CRCInput::RC_page_down) { + int direction = (msg == CRCInput::RC_page_up) ? 1 : -1; + int jump = 10; + + if (g_settings.movieplayer_bisection_jump) + { + if ((lastmsg == CRCInput::RC_page_up || lastmsg == CRCInput::RC_page_down) && (bisection_loop > -1 && bisection_loop <= 10)) + bisection_jump /= 2; + else + bisection_jump = 300; + + bisection_loop = 0; + jump = bisection_jump; + } + + SetPosition(direction*jump * 1000); } else if (msg == CRCInput::RC_0) { // cancel bookmark jump handleMovieBrowser(CRCInput::RC_0, position); } else if (msg == (neutrino_msg_t) g_settings.mpkey_goto) { @@ -1736,6 +1767,9 @@ void CMoviePlayerGui::PlayFileLoop(void) clearSubtitle(); } } + //NI + if (msg < CRCInput::RC_MaxRC) + lastmsg = msg; } printf("CMoviePlayerGui::PlayFile: exit, isMovieBrowser %d p_movie_info %p\n", isMovieBrowser, p_movie_info); playstate = CMoviePlayerGui::STOPPED; diff --git a/src/neutrino.cpp b/src/neutrino.cpp index ceb5fe5ab..702df0427 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -906,6 +906,7 @@ int CNeutrinoApp::loadSetup(const char * fname) //Movie-Player g_settings.movieplayer_repeat_on = configfile.getInt32("movieplayer_repeat_on", CMoviePlayerGui::REPEAT_OFF); + g_settings.movieplayer_bisection_jump = configfile.getInt32("movieplayer_bisection_jump", 1); //NI g_settings.youtube_dev_id = configfile.getString("youtube_dev_id","AIzaSyBLdZe7M3rpNMZqSj-3IEvjbb2hATWJIdM"); //NI g_settings.youtube_enabled = configfile.getInt32("youtube_enabled", 1); g_settings.youtube_enabled = check_youtube_dev_id(); @@ -1571,6 +1572,7 @@ void CNeutrinoApp::saveSetup(const char * fname) //Movie-Player configfile.setInt32( "movieplayer_repeat_on", g_settings.movieplayer_repeat_on ); + configfile.setInt32( "movieplayer_bisection_jump", g_settings.movieplayer_bisection_jump ); //NI configfile.setString( "youtube_dev_id", g_settings.youtube_dev_id ); configfile.setInt32( "youtube_enabled", g_settings.youtube_enabled ); configfile.setString( "tmdb_api_key", g_settings.tmdb_api_key ); diff --git a/src/system/locals.h b/src/system/locals.h index 79c7a77d1..9c9e5081e 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -1379,6 +1379,7 @@ typedef enum LOCALE_MENU_HINT_MOVIE, LOCALE_MENU_HINT_MOVIEBROWSER_FONTS, LOCALE_MENU_HINT_MOVIEBROWSER_SETUP, + LOCALE_MENU_HINT_MOVIEPLAYER_BISECTION_JUMP, LOCALE_MENU_HINT_MOVIEPLAYER_PLUGIN, LOCALE_MENU_HINT_NET_BROADCAST, LOCALE_MENU_HINT_NET_DHCP, @@ -2026,6 +2027,7 @@ typedef enum LOCALE_MOVIEBROWSER_YT_RELATED, LOCALE_MOVIEBROWSER_YT_SEARCH, LOCALE_MOVIECUT_CANCEL, + LOCALE_MOVIEPLAYER_BISECTION_JUMP, LOCALE_MOVIEPLAYER_BOOKMARK, LOCALE_MOVIEPLAYER_BOOKMARKNAME, LOCALE_MOVIEPLAYER_BOOKMARKNAME_HINT1, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 852617c36..d391c083e 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -1379,6 +1379,7 @@ const char * locale_real_names[] = "menu.hint_movie", "menu.hint_moviebrowser_fonts", "menu.hint_moviebrowser_setup", + "menu.hint_movieplayer_bisection_jump", "menu.hint_movieplayer_plugin", "menu.hint_net_broadcast", "menu.hint_net_dhcp", @@ -2026,6 +2027,7 @@ const char * locale_real_names[] = "moviebrowser.yt_related", "moviebrowser.yt_search", "moviecut.cancel", + "movieplayer.bisection_jump", "movieplayer.bookmark", "movieplayer.bookmarkname", "movieplayer.bookmarkname_hint1", diff --git a/src/system/settings.h b/src/system/settings.h index d54bb7b79..bda412206 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -787,6 +787,7 @@ struct SNeutrinoSettings //movieplayer int movieplayer_repeat_on; + int movieplayer_bisection_jump; //NI std::string youtube_dev_id; int youtube_enabled; std::string tmdb_api_key;