加盟招商网站建设方案,晋江seo,wordpress添加数据,餐饮品牌形象设计案例为cocos2d-x添加调节视频音量的功能(Android)。日常吐槽cocos。我想放广告的时候播放一些其他声音#xff0c;这时候我希望视频先静音#xff0c;但是不停止播放。等声音播放完#xff0c;我再放视频声音。赫然发现#xff0c;VideoPlayer 居然没这个接口。而且现在视频的播…为cocos2d-x添加调节视频音量的功能(Android)。日常吐槽cocos。我想放广告的时候播放一些其他声音这时候我希望视频先静音但是不停止播放。等声音播放完我再放视频声音。赫然发现VideoPlayer 居然没这个接口。而且现在视频的播放居然还没用上跨平台库而是每个平台自己实现了一套。。神坑。。。废话完毕步骤如下1.打开UIVideoPlayer.h 为此类添加一个函数virtual void setVolume(int vol); //至于放哪里随你喜欢。。希望你有基本的c知识。2.UIVideoPlayer-android.cppvoid setVideoVolumeJNI(int index, int vol){JniMethodInfo t;if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, setVideoVolume, (II)V)) {//cocos2d::log(setVideoVolumeJNI Found);t.env-CallStaticVoidMethod(t.classID, t.methodID, index, vol);t.env-DeleteLocalRef(t.classID);}else{cocos2d::log(setVideoVolumeJNI Not !!!!!!!Found!!!!!!!!);}}void VideoPlayer::setVolume(int vol){//if (!_videoURL.empty()){//cocos2d::log(VideoPlayer::setVolume %d, _videoPlayerIndex);setVideoVolumeJNI(_videoPlayerIndex, vol);}}3.Cocos2dxVideoHelper.java line69private final static int VideoTaskVolume 15;line109case VideoTaskVolume:{Log.i(hiiiiiiiiiiiiiiisetVideoVolume, setVideoVolume is setting tomsg.arg1);Cocos2dxVideoHelper helper mReference.get();helper._setVideoVolume(msg.arg1, msg.arg2);break;}line 278public static void setVideoVolume(int index, int volume){Message msg new Message();msg.what VideoTaskVolume;msg.arg1 index;msg.arg2 volume;mVideoHandler.sendMessage(msg);}private void _setVideoVolume(int index, int vol) {Cocos2dxVideoView videoView sVideoViews.get(index);if (videoView ! null) {videoView.setVideoVolume(vol);}}Cocos2dxVideoView.java line120public void setVideoVolume(int vol){if(mMediaPlayer ! null){Log.i(TAG, setVideoVolume is setting tovol);mMediaPlayer.setVolume(vol, vol);}else{Log.i(TAG, I want to setVideoVolume but mediaplayer is null...);}}因为我只有音量开关的需求 并没有调节大小的需求所以我传的INT事实上我不知道传float的IV值是什么。。请大大告知。音量值 这里只能在0.0 -1.0之间。另外请务必源码级工程下搜索并修改这些文件。如果是预编译的工程因为你没有编译c库所以是无效的。上班偷偷分享不容易。简略。