gui/luainstance.cpp: add function to start file/url play

This commit is contained in:
[CST] Focus
2014-06-12 18:57:37 +04:00
parent 81735f5e53
commit 943850eefc
2 changed files with 25 additions and 0 deletions

View File

@@ -29,6 +29,7 @@
#include <gui/widget/msgbox.h>
#include <gui/widget/messagebox.h>
#include <gui/filebrowser.h>
#include <gui/movieplayer.h>
#include <driver/pictureviewer/pictureviewer.h>
#include <neutrino.h>
@@ -408,6 +409,7 @@ const luaL_Reg CLuaInstance::methods[] =
{ "Blit", CLuaInstance::Blit },
{ "GetLanguage", CLuaInstance::GetLanguage },
{ "runScript", CLuaInstance::runScriptExt },
{ "PlayFile", CLuaInstance::PlayFile },
{ NULL, NULL }
};
@@ -565,6 +567,28 @@ int CLuaInstance::DisplayImage(lua_State *L)
return 0;
}
int CLuaInstance::PlayFile(lua_State *L)
{
printf("CLuaInstance::%s %d\n", __func__, lua_gettop(L));
int numargs = lua_gettop(L);
if (numargs < 3) {
printf("CLuaInstance::%s: not enough arguments (%d, expected 3)\n", __func__, numargs);
return 0;
}
const char *title;
const char *fname;
title = luaL_checkstring(L, 2);
fname = luaL_checkstring(L, 3);
printf("CLuaInstance::%s: title %s file %s\n", __func__, title, fname);
std::string st(title);
std::string sf(fname);
CMoviePlayerGui::getInstance().SetFile(st, sf);
CMoviePlayerGui::getInstance().exec(NULL, "http");
return 0;
}
int CLuaInstance::GetSize(lua_State *L)
{
DBG("CLuaInstance::%s %d\n", __func__, lua_gettop(L));

View File

@@ -191,6 +191,7 @@ private:
static int runScriptExt(lua_State *L);
static int GetSize(lua_State *L);
static int DisplayImage(lua_State *L);
static int PlayFile(lua_State *L);
void MenuRegister(lua_State *L);
static int MenuNew(lua_State *L);