diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 18641b641..b2d52c0a5 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -277,7 +277,6 @@ static void set_lua_variables(lua_State *L) { "EXIT_REPAINT", menu_return::RETURN_EXIT_REPAINT }, { NULL, 0 } }; - table_key apiversion[] = { { "MAJOR", LUA_API_VERSION_MAJOR }, @@ -285,6 +284,15 @@ static void set_lua_variables(lua_State *L) { NULL, 0 } }; + table_key playstate[] = + { + { "NORMAL", CMoviePlayerGui::PLUGIN_PLAYSTATE_NORMAL }, + { "STOP", CMoviePlayerGui::PLUGIN_PLAYSTATE_STOP }, + { "NEXT", CMoviePlayerGui::PLUGIN_PLAYSTATE_NEXT }, + { "PREV", CMoviePlayerGui::PLUGIN_PLAYSTATE_PREV }, + { NULL, 0 } + }; + /* list of environment variable arrays to be exported */ lua_envexport e[] = { @@ -294,6 +302,7 @@ static void set_lua_variables(lua_State *L) { "CORNER", corners }, { "MENU_RETURN", menureturn }, { "APIVERSION", apiversion }, + { "PLAYSTATE", playstate }, { NULL, NULL } }; @@ -727,8 +736,10 @@ int CLuaInstance::PlayFile(lua_State *L) std::string si2(info2); std::string sf(fname); CMoviePlayerGui::getInstance().SetFile(st, sf, si1, si2); - CMoviePlayerGui::getInstance().exec(NULL, "http"); - return 0; + CMoviePlayerGui::getInstance().exec(NULL, "http_lua"); + int ret = CMoviePlayerGui::getInstance().getKeyPressed(); + lua_pushinteger(L, ret); + return 1; } int CLuaInstance::strFind(lua_State *L) diff --git a/src/gui/luainstance.h b/src/gui/luainstance.h index 98389ef58..ee5eff3be 100644 --- a/src/gui/luainstance.h +++ b/src/gui/luainstance.h @@ -34,7 +34,7 @@ extern "C" { #include #define LUA_API_VERSION_MAJOR 1 -#define LUA_API_VERSION_MINOR 0 +#define LUA_API_VERSION_MINOR 1 /* this is stored as userdata in the lua_State */ struct CLuaData diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index f65f01796..77de4ef75 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -168,6 +168,8 @@ void CMoviePlayerGui::Init(void) info_1 = ""; info_2 = ""; filelist_it = filelist.end(); + keyPressed = CMoviePlayerGui::PLUGIN_PLAYSTATE_NORMAL; + isLuaPlay = false; } void CMoviePlayerGui::cutNeutrino() @@ -279,6 +281,12 @@ int CMoviePlayerGui::exec(CMenuTarget * parent, const std::string & actionKey) is_file_player = true; PlayFile(); } + else if (actionKey == "http_lua") { + isHTTP = true; + isLuaPlay = true; + is_file_player = true; + PlayFile(); + } else { return menu_return::RETURN_REPAINT; } @@ -402,6 +410,7 @@ void CMoviePlayerGui::ClearFlags() isMovieBrowser = false; isBookmark = false; isHTTP = false; + isLuaPlay = false; isUPNP = false; isWebTV = false; isYT = false; @@ -852,6 +861,7 @@ void CMoviePlayerGui::PlayFileLoop(void) bool update_lcd = true; int eof = 0; bool at_eof = !(playstate >= CMoviePlayerGui::PLAY);; + keyPressed = CMoviePlayerGui::PLUGIN_PLAYSTATE_NORMAL; while (playstate >= CMoviePlayerGui::PLAY) { if (update_lcd) { @@ -906,6 +916,15 @@ void CMoviePlayerGui::PlayFileLoop(void) g_PluginList->startPlugin_by_name(g_settings.movieplayer_plugin.c_str ()); } else if (msg == (neutrino_msg_t) g_settings.mpkey_stop) { 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)) { diff --git a/src/gui/movieplayer.h b/src/gui/movieplayer.h index 40dcd3a67..b18f3a71b 100644 --- a/src/gui/movieplayer.h +++ b/src/gui/movieplayer.h @@ -67,6 +67,14 @@ class CMoviePlayerGui : public CMenuTarget REW = 6 }; + enum + { + PLUGIN_PLAYSTATE_NORMAL = 0, + PLUGIN_PLAYSTATE_STOP = 1, + PLUGIN_PLAYSTATE_NEXT = 2, + PLUGIN_PLAYSTATE_PREV = 3 + }; + enum repeat_mode_enum { REPEAT_OFF = 0, REPEAT_TRACK = 1, REPEAT_ALL = 2 }; private: @@ -80,6 +88,8 @@ class CMoviePlayerGui : public CMenuTarget bool playing; bool time_forced; CMoviePlayerGui::state playstate; + int keyPressed; + bool isLuaPlay; int speed; int startposition; int position; @@ -206,6 +216,7 @@ class CMoviePlayerGui : public CMenuTarget void selectSubtitle(); void showSubtitle(neutrino_msg_data_t data); void clearSubtitle(bool lock = false); + int getKeyPressed() { return keyPressed; }; }; #endif