2019-11-23 20:27:39 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-02-24 18:51:36 +08:00
|
|
|
https://adxeproject.github.io/
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
#include "scripting/lua-bindings/manual/ui/lua_cocos2dx_video_manual.hpp"
|
2020-10-17 16:32:16 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
#include "ui/UIVideoPlayer.h"
|
|
|
|
#include "scripting/lua-bindings/manual/tolua_fix.h"
|
|
|
|
#include "scripting/lua-bindings/manual/LuaBasicConversions.h"
|
|
|
|
#include "scripting/lua-bindings/manual/CCLuaValue.h"
|
|
|
|
#include "scripting/lua-bindings/manual/CCLuaEngine.h"
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || \
|
|
|
|
CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN) && \
|
|
|
|
!defined(CC_PLATFORM_OS_TVOS)
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
static int lua_cocos2dx_video_VideoPlayer_addEventListener(lua_State* L)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
int argc = 0;
|
2019-11-23 20:27:39 +08:00
|
|
|
cocos2d::ui::VideoPlayer* self = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
# if COCOS2D_DEBUG >= 1
|
2019-11-23 20:27:39 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "ccui.VideoPlayer", 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
|
|
|
|
|
|
|
self = static_cast<cocos2d::ui::VideoPlayer*>(tolua_tousertype(L, 1, 0));
|
|
|
|
|
|
|
|
# if COCOS2D_DEBUG >= 1
|
|
|
|
if (nullptr == self)
|
|
|
|
{
|
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_cocos2dx_Widget_addTouchEventListener'\n", nullptr);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
# endif
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
argc = lua_gettop(L) - 1;
|
|
|
|
|
|
|
|
if (argc == 1)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
# if COCOS2D_DEBUG >= 1
|
|
|
|
if (!toluafix_isfunction(L, 2, "LUA_FUNCTION", 0, &tolua_err))
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
|
|
|
|
|
|
|
LUA_FUNCTION handler = (toluafix_ref_function(L, 2, 0));
|
|
|
|
|
|
|
|
self->addEventListener([=](cocos2d::Ref* ref, cocos2d::ui::VideoPlayer::EventType eventType) {
|
2019-11-23 20:27:39 +08:00
|
|
|
LuaStack* stack = LuaEngine::getInstance()->getLuaStack();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
stack->pushObject(ref, "cc.Ref");
|
|
|
|
stack->pushInt((int)eventType);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
stack->executeFunctionByHandler(handler, 2);
|
|
|
|
});
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccui.VideoPlayer:addEventListener",
|
|
|
|
argc, 0);
|
2019-11-23 20:27:39 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
# if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2019-11-23 20:27:39 +08:00
|
|
|
tolua_error(L, "#ferror in function 'lua_cocos2dx_VideoPlayer_addEventListener'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2019-11-23 20:27:39 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendVideoPlayer(lua_State* L)
|
|
|
|
{
|
|
|
|
lua_pushstring(L, "ccui.VideoPlayer");
|
|
|
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(L, -1))
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
|
|
|
tolua_function(L, "addEventListener", lua_cocos2dx_video_VideoPlayer_addEventListener);
|
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int register_all_cocos2dx_video_manual(lua_State* L)
|
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
extendVideoPlayer(L);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2020-10-17 16:32:16 +08:00
|
|
|
|
|
|
|
#endif
|