Cocos2dxVideoHelper.java :
private void _createVideoView(int index) {
Cocos2dxVideoView videoView = new Cocos2dxVideoView(mActivity,index);
sVideoViews.put(index, videoView);
FrameLayout.LayoutParams lParams = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT);
mLayout.addView(videoView, lParams);
// videoView.setZOrderOnTop(true); //注释这个
videoView.setOnCompletionListener(videoEventListener);
}
AppActivity.java :
public Cocos2dxGLSurfaceView onCreateView() {
Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this);
// glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8);
glSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 8);
glSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
return glSurfaceView;
}
Cocos2dxVideoView.java
@Override
public boolean onTouchEvent(MotionEvent event) {
// if((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP)
// {
// if (isPlaying()) {
// pause();
// } else if(mCurrentState == STATE_PAUSED){
// resume();
// }
// }
return false;
}
然后在游戏中设置背景透明度 cc.director.setClearColor(cc.color(0, 0, 0, 0));