CLuaInstance::PlayFile: Function now returns the status of buttons

- Set Lua api version to 1.1

 return code  defined LUA Variables
 --------------------------------------------------
 0 = normal exit  PLAYSTATE.NORMAL
 1 = aborted by stop button PLAYSTATE.STOP
 2 = next button  PLAYSTATE.NEXT
 3 = prev button  PLAYSTATE.PREV


Origin commit data
------------------
Branch: ni/coolstream
Commit: b56be92d59
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2015-09-04 (Fri, 04 Sep 2015)

Origin message was:
------------------
CLuaInstance::PlayFile: Function now returns the status of buttons

- Set Lua api version to 1.1

   return code       defined LUA Variables
 --------------------------------------------------
 0 = normal exit       PLAYSTATE.NORMAL
 1 = aborted by stop button  PLAYSTATE.STOP
 2 = next button       PLAYSTATE.NEXT
 3 = prev button       PLAYSTATE.PREV


------------------
This commit was generated by Migit
This commit is contained in:
Michael Liebmann
2015-09-04 13:09:43 +02:00
parent 8918159dd2
commit dc8c15bbc4
4 changed files with 45 additions and 4 deletions

View File

@@ -277,7 +277,6 @@ static void set_lua_variables(lua_State *L)
{ "EXIT_REPAINT", menu_return::RETURN_EXIT_REPAINT }, { "EXIT_REPAINT", menu_return::RETURN_EXIT_REPAINT },
{ NULL, 0 } { NULL, 0 }
}; };
table_key apiversion[] = table_key apiversion[] =
{ {
{ "MAJOR", LUA_API_VERSION_MAJOR }, { "MAJOR", LUA_API_VERSION_MAJOR },
@@ -285,6 +284,15 @@ static void set_lua_variables(lua_State *L)
{ NULL, 0 } { 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 */ /* list of environment variable arrays to be exported */
lua_envexport e[] = lua_envexport e[] =
{ {
@@ -294,6 +302,7 @@ static void set_lua_variables(lua_State *L)
{ "CORNER", corners }, { "CORNER", corners },
{ "MENU_RETURN", menureturn }, { "MENU_RETURN", menureturn },
{ "APIVERSION", apiversion }, { "APIVERSION", apiversion },
{ "PLAYSTATE", playstate },
{ NULL, NULL } { NULL, NULL }
}; };
@@ -727,8 +736,10 @@ int CLuaInstance::PlayFile(lua_State *L)
std::string si2(info2); std::string si2(info2);
std::string sf(fname); std::string sf(fname);
CMoviePlayerGui::getInstance().SetFile(st, sf, si1, si2); CMoviePlayerGui::getInstance().SetFile(st, sf, si1, si2);
CMoviePlayerGui::getInstance().exec(NULL, "http"); CMoviePlayerGui::getInstance().exec(NULL, "http_lua");
return 0; int ret = CMoviePlayerGui::getInstance().getKeyPressed();
lua_pushinteger(L, ret);
return 1;
} }
int CLuaInstance::strFind(lua_State *L) int CLuaInstance::strFind(lua_State *L)

View File

@@ -34,7 +34,7 @@ extern "C" {
#include <vector> #include <vector>
#define LUA_API_VERSION_MAJOR 1 #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 */ /* this is stored as userdata in the lua_State */
struct CLuaData struct CLuaData

View File

@@ -168,6 +168,8 @@ void CMoviePlayerGui::Init(void)
info_1 = ""; info_1 = "";
info_2 = ""; info_2 = "";
filelist_it = filelist.end(); filelist_it = filelist.end();
keyPressed = CMoviePlayerGui::PLUGIN_PLAYSTATE_NORMAL;
isLuaPlay = false;
} }
void CMoviePlayerGui::cutNeutrino() void CMoviePlayerGui::cutNeutrino()
@@ -279,6 +281,12 @@ int CMoviePlayerGui::exec(CMenuTarget * parent, const std::string & actionKey)
is_file_player = true; is_file_player = true;
PlayFile(); PlayFile();
} }
else if (actionKey == "http_lua") {
isHTTP = true;
isLuaPlay = true;
is_file_player = true;
PlayFile();
}
else { else {
return menu_return::RETURN_REPAINT; return menu_return::RETURN_REPAINT;
} }
@@ -402,6 +410,7 @@ void CMoviePlayerGui::ClearFlags()
isMovieBrowser = false; isMovieBrowser = false;
isBookmark = false; isBookmark = false;
isHTTP = false; isHTTP = false;
isLuaPlay = false;
isUPNP = false; isUPNP = false;
isWebTV = false; isWebTV = false;
isYT = false; isYT = false;
@@ -852,6 +861,7 @@ void CMoviePlayerGui::PlayFileLoop(void)
bool update_lcd = true; bool update_lcd = true;
int eof = 0; int eof = 0;
bool at_eof = !(playstate >= CMoviePlayerGui::PLAY);; bool at_eof = !(playstate >= CMoviePlayerGui::PLAY);;
keyPressed = CMoviePlayerGui::PLUGIN_PLAYSTATE_NORMAL;
while (playstate >= CMoviePlayerGui::PLAY) while (playstate >= CMoviePlayerGui::PLAY)
{ {
if (update_lcd) { if (update_lcd) {
@@ -906,6 +916,15 @@ void CMoviePlayerGui::PlayFileLoop(void)
g_PluginList->startPlugin_by_name(g_settings.movieplayer_plugin.c_str ()); g_PluginList->startPlugin_by_name(g_settings.movieplayer_plugin.c_str ());
} else if (msg == (neutrino_msg_t) g_settings.mpkey_stop) { } else if (msg == (neutrino_msg_t) g_settings.mpkey_stop) {
playstate = CMoviePlayerGui::STOPPED; 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(); ClearQueue();
} else if ((!filelist.empty() && msg == (neutrino_msg_t) CRCInput::RC_right)) { } else if ((!filelist.empty() && msg == (neutrino_msg_t) CRCInput::RC_right)) {
if (filelist_it < (filelist.end() - 1)) { if (filelist_it < (filelist.end() - 1)) {

View File

@@ -67,6 +67,14 @@ class CMoviePlayerGui : public CMenuTarget
REW = 6 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 }; enum repeat_mode_enum { REPEAT_OFF = 0, REPEAT_TRACK = 1, REPEAT_ALL = 2 };
private: private:
@@ -80,6 +88,8 @@ class CMoviePlayerGui : public CMenuTarget
bool playing; bool playing;
bool time_forced; bool time_forced;
CMoviePlayerGui::state playstate; CMoviePlayerGui::state playstate;
int keyPressed;
bool isLuaPlay;
int speed; int speed;
int startposition; int startposition;
int position; int position;
@@ -206,6 +216,7 @@ class CMoviePlayerGui : public CMenuTarget
void selectSubtitle(); void selectSubtitle();
void showSubtitle(neutrino_msg_data_t data); void showSubtitle(neutrino_msg_data_t data);
void clearSubtitle(bool lock = false); void clearSubtitle(bool lock = false);
int getKeyPressed() { return keyPressed; };
}; };
#endif #endif