cocos js android 添加视频循环播放
16lz
2021-01-23
Cocos2dxVideoView.java:private boolean isLoop = false;//添加方法public void setLooping(boolean loop) { this.isLoop = loop; if(mMediaPlayer!=null){ mMediaPlayer.setLooping(loop); }}//修改public void start() { if (isInPlaybackState()) { if(this.isLoop){ //播放的时候设置为循环播放 this.setLooping(true); } mMediaPlayer.start(); mCurrentState = STATE_PLAYING; if (mOnVideoEventListener != null) { mOnVideoEventListener.onVideoEvent(mViewTag, EVENT_PLAYING); } } mTargetState = STATE_PLAYING;}Cocos2dxVideoHelper.java:private final static int VideoTaskSetLooping = 13;@Overridepublic void handleMessage(Message msg) {case VideoTaskSetLooping:{ //_setLooping Cocos2dxVideoHelper helper = mReference.get(); if(msg.arg2 == 0){ helper._setVideoLooping(msg.arg1,false); }else{ helper._setVideoLooping(msg.arg1,true); }break; }}public static void setVideoLooping(int index,int isLoop) { Message msg = new Message(); msg.what = VideoTaskSetLooping; msg.arg1 = index; msg.arg2 = isLoop; mVideoHandler.sendMessage(msg);} public void _setVideoLooping(int index,boolean isLoop) { Cocos2dxVideoView view = sVideoViews.get(index); if(view!=null){ view.setLooping(isLoop); }}C:\Cocos\frameworks\cocos2d-x-3.9\cocos\ui\UIVideoPlayer.hvirtual void setVideoLooping(bool isLoop);C:\Cocos\frameworks\cocos2d-x-3.9\cocos\ui\UIVideoPlayer-android.cppvoid VideoPlayer::setVideoLooping(bool isLoop){if (isLoop) {setVideoLoopingJNI(_videoPlayerIndex, 1);}else {setVideoLoopingJNI(_videoPlayerIndex, 0);}}void setVideoLoopingJNI(int index, int isLoop) {JniMethodInfo t;if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setVideoLooping", "(II)V")) {t.env->CallStaticVoidMethod(t.classID, t.methodID, index, isLoop);t.env->DeleteLocalRef(t.classID);}}C:\Cocos\frameworks\cocos2d-x-3.9\cocos\scripting\js-bindings\auto\jsb_cocos2dx_experimental_video_auto.hppbool js_cocos2dx_experimental_video_VideoPlayer_setVideoLooping(JSContext *cx, uint32_t argc, jsval *vp);C:\Cocos\frameworks\cocos2d-x-3.9\cocos\scripting\js-bindings\auto\jsb_cocos2dx_experimental_video_auto.cppbool js_cocos2dx_experimental_video_VideoPlayer_setVideoLooping(JSContext *cx, uint32_t argc, jsval *vp){JS::CallArgs args = JS::CallArgsFromVp(argc, vp);bool ok = true;JS::RootedObject obj(cx, args.thisv().toObjectOrNull());js_proxy_t *proxy = jsb_get_js_proxy(obj);cocos2d::experimental::ui::VideoPlayer* cobj = (cocos2d::experimental::ui::VideoPlayer *)(proxy ? proxy->ptr : NULL);JSB_PRECONDITION2(cobj, cx, false, "js_cocos2dx_experimental_video_VideoPlayer_setVideoLooping : Invalid Native Object");if (argc == 1) {bool arg0;arg0 = JS::ToBoolean(args.get(0));JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_experimental_video_VideoPlayer_setVideoLooping : Error processing arguments");cobj->setVideoLooping(arg0);args.rval().setUndefined();return true;}JS_ReportError(cx, "js_cocos2dx_experimental_video_VideoPlayer_setVideoLooping : wrong number of arguments: %d, was expecting %d", argc, 1);return false;}static JSFunctionSpec funcs[] = { //注册方法JS_FN("setVideoLooping", js_cocos2dx_experimental_video_VideoPlayer_setVideoLooping, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END};
更多相关文章
- GPS开发常用方法 和用Criteria确定android location providerGPS
- Android Dialog触摸对话框外部让其消失的实现方法
- android 获取当前时间的方法
- Android ScrollView嵌套ViewPager不显示和出现空白部分 解决方法
- Android查询所有联系人和根据号码查询联系人方法
- Android系统信息查看方法