版本
1.x
2.x 的版本Web可行,在iOS中Canvas层不渲染,还未找到原因
原理
无论在哪个环境下,Cocos的默认实现都是把视频层作为Canvas的一个子视图。实现Canvas在视频上方的原理就是让两者同层
Web
iOS
在 AppController.h 添加
@property(nonatomic, readonly) UIView* videoView;
在 AppController.mm 修改
// Add super view to make canvas on top of video player
_viewController.view.tag = 3;
UIViewController* uiVC = [[UIViewController alloc] initWithNibName:nil bundle:nil];
uiVC.view.frame = [UIScreen mainScreen].bounds;
_videoView = [[UIView alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
_videoView.tag = 1; //设置tag以便之后把Video层取出来~
[uiVC.view addSubview:_videoView];
[uiVC.view addSubview:_viewController.view];
// Set RootViewController to window
if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
{
// warning: addSubView doesn't work on iOS6
[window addSubview: uiVC.view];
}
else
{
// use this method on ios6
[window setRootViewController:uiVC];
}
在 UIVideoPlayer-ios.mm 修改
[[eaglview.superview viewWithTag:1] addSubview:volumeView];
[[eaglview.superview viewWithTag:1] addSubview:self.moviePlayer.view];