Skip to content

Video player test #1670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions frameworks/js-bindings/bindings/Android.mk
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ LOCAL_SRC_FILES := auto/jsb_cocos2dx_auto.cpp \
auto/jsb_cocos2dx_ui_auto.cpp \
auto/jsb_cocos2dx_3d_auto.cpp \
auto/jsb_cocos2dx_3d_extension_auto.cpp \
auto/jsb_cocos2dx_experimental_video_auto.cpp \
manual/ScriptingCore.cpp \
manual/cocos2d_specifics.cpp \
manual/js_manual_conversions.cpp \
@@ -41,8 +42,8 @@ LOCAL_SRC_FILES := auto/jsb_cocos2dx_auto.cpp \
manual/network/XMLHTTPRequest.cpp \
manual/spine/jsb_cocos2dx_spine_manual.cpp \
manual/ui/jsb_cocos2dx_ui_manual.cpp \
manual/3d/jsb_cocos2dx_3d_manual.cpp

manual/3d/jsb_cocos2dx_3d_manual.cpp \
manual/experimental/jsb_cocos2dx_experimental_video_manual.cpp

LOCAL_CFLAGS := -DCOCOS2D_JAVASCRIPT

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include "jsb_cocos2dx_experimental_video_manual.h"

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)

#include "UIVideoPlayer.h"
#include "ScriptingCore.h"
#include "cocos2d_specifics.hpp"
#include "cocos2d.h"

using namespace cocos2d;


static bool jsb_cocos2dx_experimental_ui_VideoPlayer_addEventListener(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy = jsb_get_js_proxy(obj);
experimental::ui::VideoPlayer* cobj = (experimental::ui::VideoPlayer *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object");

if(argc == 1){
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, obj, args.get(0)));
cobj->addEventListener([=](Ref* widget, experimental::ui::VideoPlayer::EventType type)->void{
jsval arg[2];
js_proxy_t *proxy = js_get_or_create_proxy(cx, widget);
if(proxy)
arg[0] = OBJECT_TO_JSVAL(proxy->obj);
else
arg[0] = JSVAL_NULL;
arg[1] = int32_to_jsval(cx, (int32_t)type);
JS::RootedValue rval(cx);

bool ok = func->invoke(2, arg, &rval);
if (!ok && JS_IsExceptionPending(cx)) {
JS_ReportPendingException(cx);
}
});
return true;
}
}

extern JSObject* jsb_cocos2d_experimental_ui_VideoPlayer_prototype;

void register_all_cocos2dx_experimental_video_manual(JSContext* cx, JS::HandleObject global)
{
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_experimental_ui_VideoPlayer_prototype), "addEventListener", jsb_cocos2dx_experimental_ui_VideoPlayer_addEventListener, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
}

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef __jsb_cocos2dx_experimental_video_manual__
#define __jsb_cocos2dx_experimental_video_manual__

#include "jsapi.h"
#include "jsfriendapi.h"

void register_all_cocos2dx_experimental_video_manual(JSContext* cx, JS::HandleObject global);

#endif /* defined(__jsb_cocos2dx_experimental_video_manual__) */
Original file line number Diff line number Diff line change
@@ -146,6 +146,12 @@
420BBCF81AA48EE900493976 /* jsb_cocos2dx_3d_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBCF51AA48EE900493976 /* jsb_cocos2dx_3d_manual.cpp */; };
420BBCF91AA48EE900493976 /* jsb_cocos2dx_3d_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 420BBCF61AA48EE900493976 /* jsb_cocos2dx_3d_manual.h */; };
420BBCFA1AA48EE900493976 /* jsb_cocos2dx_3d_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 420BBCF61AA48EE900493976 /* jsb_cocos2dx_3d_manual.h */; };
4BE089C81ADF6A8200D65D4B /* jsb_cocos2dx_experimental_webView_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BE089C41ADF6A8200D65D4B /* jsb_cocos2dx_experimental_webView_auto.cpp */; };
4BE089C91ADF6A8200D65D4B /* jsb_cocos2dx_experimental_webView_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 4BE089C51ADF6A8200D65D4B /* jsb_cocos2dx_experimental_webView_auto.hpp */; };
4BE089CA1ADF6A8200D65D4B /* jsb_cocos2dx_experimental_video_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BE089C61ADF6A8200D65D4B /* jsb_cocos2dx_experimental_video_auto.cpp */; };
4BE089CB1ADF6A8200D65D4B /* jsb_cocos2dx_experimental_video_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 4BE089C71ADF6A8200D65D4B /* jsb_cocos2dx_experimental_video_auto.hpp */; };
4BE089D01ADF8C1800D65D4B /* jsb_cocos2dx_experimental_video_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BE089CE1ADF8C1800D65D4B /* jsb_cocos2dx_experimental_video_manual.cpp */; };
4BE089D11ADF8C1800D65D4B /* jsb_cocos2dx_experimental_video_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BE089CF1ADF8C1800D65D4B /* jsb_cocos2dx_experimental_video_manual.h */; };
83A5661918DA878400FC31A0 /* jsb_socketio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83A5661718DA878400FC31A0 /* jsb_socketio.cpp */; };
83A5661A18DA878400FC31A0 /* jsb_socketio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83A5661718DA878400FC31A0 /* jsb_socketio.cpp */; };
83A5661B18DA878400FC31A0 /* jsb_socketio.h in Headers */ = {isa = PBXBuildFile; fileRef = 83A5661818DA878400FC31A0 /* jsb_socketio.h */; };
@@ -256,6 +262,12 @@
420BBCEF1AA48EDE00493976 /* jsb_cocos2dx_3d_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_3d_auto.hpp; sourceTree = "<group>"; };
420BBCF51AA48EE900493976 /* jsb_cocos2dx_3d_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_3d_manual.cpp; sourceTree = "<group>"; };
420BBCF61AA48EE900493976 /* jsb_cocos2dx_3d_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_cocos2dx_3d_manual.h; sourceTree = "<group>"; };
4BE089C41ADF6A8200D65D4B /* jsb_cocos2dx_experimental_webView_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_experimental_webView_auto.cpp; sourceTree = "<group>"; };
4BE089C51ADF6A8200D65D4B /* jsb_cocos2dx_experimental_webView_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_experimental_webView_auto.hpp; sourceTree = "<group>"; };
4BE089C61ADF6A8200D65D4B /* jsb_cocos2dx_experimental_video_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_experimental_video_auto.cpp; sourceTree = "<group>"; };
4BE089C71ADF6A8200D65D4B /* jsb_cocos2dx_experimental_video_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_experimental_video_auto.hpp; sourceTree = "<group>"; };
4BE089CE1ADF8C1800D65D4B /* jsb_cocos2dx_experimental_video_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_experimental_video_manual.cpp; sourceTree = "<group>"; };
4BE089CF1ADF8C1800D65D4B /* jsb_cocos2dx_experimental_video_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_cocos2dx_experimental_video_manual.h; sourceTree = "<group>"; };
83A5661718DA878400FC31A0 /* jsb_socketio.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_socketio.cpp; sourceTree = "<group>"; };
83A5661818DA878400FC31A0 /* jsb_socketio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_socketio.h; sourceTree = "<group>"; };
BA4095C01A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_studio_conversions.cpp; sourceTree = "<group>"; };
@@ -323,6 +335,10 @@
1A119E2E18BDF19200352BAA /* auto */ = {
isa = PBXGroup;
children = (
4BE089C41ADF6A8200D65D4B /* jsb_cocos2dx_experimental_webView_auto.cpp */,
4BE089C51ADF6A8200D65D4B /* jsb_cocos2dx_experimental_webView_auto.hpp */,
4BE089C61ADF6A8200D65D4B /* jsb_cocos2dx_experimental_video_auto.cpp */,
4BE089C71ADF6A8200D65D4B /* jsb_cocos2dx_experimental_video_auto.hpp */,
420BBCEE1AA48EDE00493976 /* jsb_cocos2dx_3d_auto.cpp */,
420BBCEF1AA48EDE00493976 /* jsb_cocos2dx_3d_auto.hpp */,
BAEE4D6F1AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.cpp */,
@@ -349,6 +365,7 @@
1A119E4118BDF19200352BAA /* manual */ = {
isa = PBXGroup;
children = (
4BE089CD1ADF8C1800D65D4B /* experimental */,
420BBCF41AA48EE900493976 /* 3d */,
0541A74C1973876100E45470 /* ios */,
1A119E4218BDF19200352BAA /* chipmunk */,
@@ -525,6 +542,15 @@
path = 3d;
sourceTree = "<group>";
};
4BE089CD1ADF8C1800D65D4B /* experimental */ = {
isa = PBXGroup;
children = (
4BE089CE1ADF8C1800D65D4B /* jsb_cocos2dx_experimental_video_manual.cpp */,
4BE089CF1ADF8C1800D65D4B /* jsb_cocos2dx_experimental_video_manual.h */,
);
path = experimental;
sourceTree = "<group>";
};
BA623DFB191A192700761F37 /* pluginx */ = {
isa = PBXGroup;
children = (
@@ -604,6 +630,7 @@
1A119F0218BDF19200352BAA /* ScriptingCore.h in Headers */,
1A119EBE18BDF19200352BAA /* cocos2d_specifics.hpp in Headers */,
83A5661C18DA878400FC31A0 /* jsb_socketio.h in Headers */,
4BE089CB1ADF6A8200D65D4B /* jsb_cocos2dx_experimental_video_auto.hpp in Headers */,
1A1D3B7B18C44FD000922D3C /* jsb_event_dispatcher_manual.h in Headers */,
1A119EF618BDF19200352BAA /* js_bindings_system_registration.h in Headers */,
BA4095C51A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.h in Headers */,
@@ -614,6 +641,7 @@
1A119EFA18BDF19200352BAA /* jsb_websocket.h in Headers */,
1A119E9218BDF19200352BAA /* jsb_cocos2dx_extension_auto.hpp in Headers */,
1A119E8C18BDF19200352BAA /* jsb_cocos2dx_builder_auto.hpp in Headers */,
4BE089C91ADF6A8200D65D4B /* jsb_cocos2dx_experimental_webView_auto.hpp in Headers */,
BA623E19191A196F00761F37 /* jsb_cocos2dx_pluginx_auto.hpp in Headers */,
1A119EAA18BDF19200352BAA /* js_bindings_chipmunk_auto_classes.h in Headers */,
1A119E9E18BDF19200352BAA /* jsb_cocos2dx_spine_auto.hpp in Headers */,
@@ -631,6 +659,7 @@
1AB5E63618D05BF30088DAA4 /* jsb_cocos2dx_ui_manual.h in Headers */,
1A119EE418BDF19200352BAA /* jsb_opengl_functions.h in Headers */,
BA623E10191A195F00761F37 /* jsb_pluginx_manual_protocols.h in Headers */,
4BE089D11ADF8C1800D65D4B /* jsb_cocos2dx_experimental_video_manual.h in Headers */,
1AB5E62E18D05BC80088DAA4 /* jsb_cocos2dx_ui_auto.hpp in Headers */,
1A119EDA18BDF19200352BAA /* js_bindings_opengl.h in Headers */,
1A119EC818BDF19200352BAA /* jsb_cocos2dx_studio_manual.h in Headers */,
@@ -768,6 +797,7 @@
1A119EEE18BDF19200352BAA /* js_bindings_system_functions.cpp in Sources */,
1A119EB418BDF19200352BAA /* js_bindings_chipmunk_manual.cpp in Sources */,
1A119EEA18BDF19200352BAA /* jsb_opengl_registration.cpp in Sources */,
4BE089CA1ADF6A8200D65D4B /* jsb_cocos2dx_experimental_video_auto.cpp in Sources */,
1A119EF818BDF19200352BAA /* jsb_websocket.cpp in Sources */,
1A119ED418BDF19200352BAA /* js_bindings_core.cpp in Sources */,
420BBCF11AA48EDE00493976 /* jsb_cocos2dx_3d_auto.cpp in Sources */,
@@ -778,9 +808,11 @@
1A119ED818BDF19200352BAA /* js_bindings_opengl.cpp in Sources */,
1AB5E62C18D05BC80088DAA4 /* jsb_cocos2dx_ui_auto.cpp in Sources */,
1A119E9C18BDF19200352BAA /* jsb_cocos2dx_spine_auto.cpp in Sources */,
4BE089C81ADF6A8200D65D4B /* jsb_cocos2dx_experimental_webView_auto.cpp in Sources */,
1A119EF418BDF19200352BAA /* js_bindings_system_registration.cpp in Sources */,
1A119EBC18BDF19200352BAA /* cocos2d_specifics.cpp in Sources */,
1A119EE618BDF19200352BAA /* jsb_opengl_manual.cpp in Sources */,
4BE089D01ADF8C1800D65D4B /* jsb_cocos2dx_experimental_video_manual.cpp in Sources */,
1A119F0618BDF19200352BAA /* jsb_cocos2dx_spine_manual.cpp in Sources */,
BA623E0F191A195F00761F37 /* jsb_pluginx_manual_protocols.cpp in Sources */,
BA623E13191A195F00761F37 /* pluginxUTF8.cpp in Sources */,
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2013-2014 Chukong Technologies Inc.
*
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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.
*/

var ccexp = ccexp || {};

ccexp.VideoPlayer.PLAYING = 0;
ccexp.VideoPlayer.PAUSED = 1;
ccexp.VideoPlayer.STOPPED = 2;
ccexp.VideoPlayer.COMPLETED = 3;
4 changes: 4 additions & 0 deletions frameworks/js-bindings/bindings/script/jsb.js
Original file line number Diff line number Diff line change
@@ -136,4 +136,8 @@ if (jsb.Sprite3D){

if (jsb.ParticleSystem3D) {
require('script/3d/jsb_cocos2d_3d_ext.js');
}

if (window.ccexp) {
require('script/experimental/jsb_experimental.js');
}
2 changes: 2 additions & 0 deletions samples/js-tests/project.json
Original file line number Diff line number Diff line change
@@ -168,6 +168,8 @@
"src/GUITest/UITextFieldTest/UITextFieldTest.js",
"src/GUITest/UIRichTextTest/UIRichTextTest.js",
"src/GUITest/UITextTest/UITextTest.js",
"src/GUITest/UIVideoPlayerTest/UIVideoPlayerTest.js",


"src/CocoStudioTest/SceneTest/TriggerCode/Acts.js",
"src/CocoStudioTest/SceneTest/TriggerCode/Cons.js",
10 changes: 10 additions & 0 deletions samples/js-tests/project/Classes/AppDelegate.cpp
Original file line number Diff line number Diff line change
@@ -42,6 +42,11 @@
#include "js_Effect3D_bindings.h"
#endif

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#include "jsb_cocos2dx_experimental_video_auto.hpp"
#include "experimental/jsb_cocos2dx_experimental_video_manual.h"
#endif

USING_NS_CC;
USING_NS_CC_EXT;
using namespace CocosDenshion;
@@ -126,6 +131,11 @@ bool AppDelegate::applicationDidFinishLaunching()
sc->addRegisterCallback(register_Effect3D_bindings);
#endif

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
sc->addRegisterCallback(register_all_cocos2dx_experimental_video);
sc->addRegisterCallback(register_all_cocos2dx_experimental_video_manual);
#endif

sc->start();
sc->runScript("script/jsb_boot.js");
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
Binary file added samples/js-tests/res/cocosvideo.mp4
Binary file not shown.
8 changes: 8 additions & 0 deletions samples/js-tests/src/GUITest/UISceneManager.js
Original file line number Diff line number Diff line change
@@ -28,6 +28,14 @@
var currentTestingArray = null;

var testingItems = {
"UIVideoPlayerTest": [
{
title: "UIVideoPlayerTest",
func: function () {
return new UIVideoPlayerTest();
}
}
],
"UIButton": [
{
title: "UIButtonTest",
176 changes: 176 additions & 0 deletions samples/js-tests/src/GUITest/UIVideoPlayerTest/UIVideoPlayerTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
/****************************************************************************
Copyright (c) 2011-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
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:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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.
****************************************************************************/

//2015-04-14

var UIVideoPlayerTest = UIScene.extend({
_visibleOrigin:null,
_visibleSize:null,
_videoStateLabel:null,
_videoPlayer:null,
init: function(){
if (this._super()) {

if (!cc.sys.isNative)
{
return true;
}

this._visibleSize = cc.size(480, 320);
this._visibleOrigin = cc.view.getVisibleOrigin();

cc.MenuItemFont.setFontSize(16);

var fullSwitch = new cc.MenuItemFont("FullScreenSwitch", this.menuFullScreenCallback, this);
fullSwitch.setAnchorPoint(cc.p(0, 0));
fullSwitch.setPosition(cc.p(this._visibleOrigin.x + 10, this._visibleOrigin.y + 50));

var pauseItem = new cc.MenuItemFont("Pause", this.menuPauseCallback, this);
pauseItem.setAnchorPoint(cc.p(0, 0));
pauseItem.setPosition(cc.p(this._visibleOrigin.x + 10, this._visibleOrigin.y + 100));

var resumeItem = new cc.MenuItemFont("Resume", this.menuResumeCallback, this);
resumeItem.setAnchorPoint(cc.p(0, 0));
resumeItem.setPosition(cc.p(this._visibleOrigin.x + 10, this._visibleOrigin.y + 150));

var stopItem = new cc.MenuItemFont("Stop", this.menuStopCallback, this);
stopItem.setAnchorPoint(cc.p(0, 0));
stopItem.setPosition(cc.p(this._visibleOrigin.x + 10, this._visibleOrigin.y + 200));

var hintItem = new cc.MenuItemFont("Hint", this.menuHintCallback, this);
hintItem.setAnchorPoint(cc.p(0, 0));
hintItem.setPosition(cc.p(this._visibleOrigin.x + 10, this._visibleOrigin.y + 250));

//-------------------------------------------------------------------------------------------------------------------

var resourceVideo = new cc.MenuItemFont("Play resource video", this.menuResourceVideoCallback, this);
resourceVideo.setAnchorPoint(cc.p(1, 0.5));
resourceVideo.setPosition(cc.p(this._visibleOrigin.x + this._visibleSize.width - 10, this._visibleOrigin.y + 50));

var onlineVideo = new cc.MenuItemFont("Play online video", this.menuOnlineVideoCallback, this);
onlineVideo.setAnchorPoint(cc.p(1, 0.5));
onlineVideo.setPosition(cc.p(this._visibleOrigin.x + this._visibleSize.width - 10, this._visibleOrigin.y + 100));

var ratioSwitch = new cc.MenuItemFont("KeepRatioSwitch", this.menuRatioCallback, this);
ratioSwitch.setAnchorPoint(cc.p(1, 0.5));
ratioSwitch.setPosition(cc.p(this._visibleOrigin.x + this._visibleSize.width - 10, this._visibleOrigin.y + 150));

var menu = new cc.Menu(resourceVideo,onlineVideo,ratioSwitch,fullSwitch,pauseItem,resumeItem,stopItem,hintItem);
menu.setPosition(cc.p(0, 0));
this._mainNode.addChild(menu);

this._videoStateLabel = new cc.LabelTTF("IDLE","Arial",16);
this._videoStateLabel.setAnchorPoint(cc.p(1, 0.5));
this._videoStateLabel.setPosition(cc.p(this._visibleOrigin.x + this._visibleSize.width - 10, this._visibleOrigin.y + 200));
this._mainNode.addChild(this._videoStateLabel);

this.createVideo();
return true;
}
},
createVideo: function() {
var centerPos = cc.p(this._visibleOrigin.x + this._visibleSize.width / 2, this._visibleOrigin.y + this._visibleSize.height /2);

var widgetSize = this._widget.getContentSize();

this._videoPlayer = new ccexp.VideoPlayer();
this._videoPlayer.setPosition(centerPos);
this._videoPlayer.setAnchorPoint(cc.p(0.5, 0.5));
this._videoPlayer.setContentSize(cc.size(widgetSize.width * 0.4, widgetSize.height * 0.4));
this._mainNode.addChild(this._videoPlayer);

this._videoPlayer.addEventListener(this.videoEventCallback.bind(this));
},
videoEventCallback: function (sender, eventType)
{
cc.log("videoEventCallback eventType:" + eventType);
switch (eventType) {
case ccexp.VideoPlayer.PLAYING:
this._videoStateLabel.setString("PLAYING");
break;
case ccexp.VideoPlayer.PAUSED:
this._videoStateLabel.setString("PAUSED");
break;
case ccexp.VideoPlayer.STOPPED:
this._videoStateLabel.setString("STOPPED");
break;
case ccexp.VideoPlayer.COMPLETED:
this._videoStateLabel.setString("COMPLETED");
break;
default:
break;
}
},
menuFullScreenCallback: function() {
if (this._videoPlayer)
{
this._videoPlayer.setFullScreenEnabled(! this._videoPlayer.isFullScreenEnabled());
}
},
menuPauseCallback: function() {
if (this._videoPlayer)
{
this._videoPlayer.pause();
}
},
menuResumeCallback: function() {
if (this._videoPlayer)
{
this._videoPlayer.resume();
}
},
menuStopCallback: function() {
if (this._videoPlayer)
{
this._videoPlayer.stop();
}
},
menuHintCallback: function() {
if (this._videoPlayer)
{
this._videoPlayer.setVisible(! this._videoPlayer.isVisible());
}
},
menuResourceVideoCallback: function() {
if (this._videoPlayer)
{
this._videoPlayer.setFileName("res/cocosvideo.mp4");
this._videoPlayer.play();
}
},
menuOnlineVideoCallback: function() {
if (this._videoPlayer)
{
this._videoPlayer.setURL("http://benchmark.cocos2d-x.org/cocosvideo.mp4");
this._videoPlayer.play();
}
},
menuRatioCallback: function() {
if (this._videoPlayer)
{
this._videoPlayer.setKeepAspectRatioEnabled(! this._videoPlayer.isKeepAspectRatioEnabled());
}
}
});
3 changes: 2 additions & 1 deletion samples/js-tests/src/tests_resources.js
Original file line number Diff line number Diff line change
@@ -954,7 +954,8 @@ var g_ui = [
"res/cocosui/100/1000.plist",
"res/cocosui/100/1000.png",
s_s9s_blocks9_plist,
"res/cocosui/CloseSelected.png"
"res/cocosui/CloseSelected.png",
"res/cocosvideo.mp4"
];

var g_performace = [
62 changes: 62 additions & 0 deletions tools/tojs/cocos2dx_experimental_video.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[cocos2dx_experimental_video]
# the prefix to be added to the generated functions. You might or might not use this in your own
# templates
prefix = cocos2dx_experimental_video

# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`)
# all classes will be embedded in that namespace
target_namespace = ccexp

macro_judgement = #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)

android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include
android_flags = -D_SIZE_T_DEFINED_

clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include
clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__

cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android

cocos_flags = -DANDROID

cxxgenerator_headers =

# extra arguments for clang
extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s

# what headers to parse
headers = %(cocosdir)s/cocos/ui/UIVideoPlayer.h

# what classes to produce code for. You can use regular expressions here. When testing the regular
# expression, it will be enclosed in "^$", like this: "^Menu*$".
classes = VideoPlayer

# what should we skip? in the format ClassName::[function function]
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just
# add a single "*" as functions. See bellow for several examples. A special class name is "*", which
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
# functions from all classes.

skip = VideoPlayer::[addEventListener]

rename_functions =

rename_classes =

# for all class names, should we remove something when registering in the target VM?
remove_prefix =

# classes for which there will be no "parent" lookup
classes_have_no_parents =

# base classes which will be skipped when their sub-classes found them.
base_classes_to_skip =

# classes that create no constructor
# Set is special and we will use a hand-written constructor
abstract_classes =

# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'.
script_control_cpp = no

4 changes: 2 additions & 2 deletions tools/tojs/cocos2dx_ui.ini
Original file line number Diff line number Diff line change
@@ -30,9 +30,9 @@ headers = %(cocosdir)s/cocos/ui/CocosGUI.h

# what classes to produce code for. You can use regular expressions here. When testing the regular
# expression, it will be enclosed in "^$", like this: "^Menu*$".
classes = Helper Layout Widget Button CheckBox ImageView Text TextAtlas TextBMFont RichText RichElement RichElementText RichElementImage RichElementCustomNode LoadingBar Slider TextField UICCTextField ScrollView PageView ListView LayoutParameter LinearLayoutParameter RelativeLayoutParameter VideoPlayer HBox VBox RelativeBox Scale9Sprite EditBox$ LayoutComponent
classes = Helper Layout Widget Button CheckBox ImageView Text TextAtlas TextBMFont RichText RichElement RichElementText RichElementImage RichElementCustomNode LoadingBar Slider TextField UICCTextField ScrollView PageView ListView LayoutParameter LinearLayoutParameter RelativeLayoutParameter HBox VBox RelativeBox Scale9Sprite EditBox$ LayoutComponent

classes_need_extend = Layout Widget Button CheckBox ImageView Text TextAtlas TextBMFont RichText RichElement RichElementText RichElementImage RichElementCustomNode LoadingBar Slider TextField ScrollView PageView ListView VideoPlayer HBox VBox RelativeBox Scale9Sprite EditBox$ LayoutComponent
classes_need_extend = Layout Widget Button CheckBox ImageView Text TextAtlas TextBMFont RichText RichElement RichElementText RichElementImage RichElementCustomNode LoadingBar Slider TextField ScrollView PageView ListView HBox VBox RelativeBox Scale9Sprite EditBox$ LayoutComponent

# what should we skip? in the format ClassName::[function function]
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
3 changes: 2 additions & 1 deletion tools/tojs/genbindings.py
Original file line number Diff line number Diff line change
@@ -141,7 +141,8 @@ def main():
'cocos2dx_studio.ini' : ('cocos2dx_studio', 'jsb_cocos2dx_studio_auto'), \
'cocos2dx_spine.ini' : ('cocos2dx_spine', 'jsb_cocos2dx_spine_auto'), \
'cocos2dx_3d.ini' : ('cocos2dx_3d', 'jsb_cocos2dx_3d_auto'), \
'cocos2dx_3d_ext.ini' : ('cocos2dx_3d_extension', 'jsb_cocos2dx_3d_extension_auto')
'cocos2dx_3d_ext.ini' : ('cocos2dx_3d_extension', 'jsb_cocos2dx_3d_extension_auto'), \
'cocos2dx_experimental_video.ini' : ('cocos2dx_experimental_video', 'jsb_cocos2dx_experimental_video_auto')
}
target = 'spidermonkey'
generator_py = '%s/generator.py' % cxx_generator_root