MPMovIEPlayerVIEwController或MPMovIEPlayerController播放本地视频报错:
_itemFailedtoplayToEnd: {
kind = 1;
new = 2;
old = 0;
}
cocos2dx vIDeovIEw ios播放错误问题
在网上搜了很多解决方法都没解决掉。后来发现是url错误。
错误代码:
[objc] view plain copy Nsstring*path=[[NSBundlemainBundle]pathForResource:@"test.MOV"ofType:nilnil]; MPMovIEPlayerVIEwController*mpvc=[[MPMovIEPlayerVIEwControlleralloc]initWithContentURL:[NSURLURLWithString:path]]; mpvc.movIEPlayer.fullscreen=YES; mpvc.movIEPlayer.movIESourceType=MPMovIESourceTypefile;
正确代码:
fileURLWithPath:区别仅仅在创建url实例所使用的类方法:
[NSURLpath] 生成的URL是:/var/mobile/Applications/3C78D5FF-8953-4AC2-BF5A-293261A5468E/TestVIDeo.app/test.MOV
生成的URL是:file:///var/mobile/Applications/3C78D5FF-8953-4AC2-BF5A-293261A5468E/TestVIDeo.app/test.MOV
看出区别来了吧。
上面是别人的博客内容
修改一下cocos/ui/UIVIDeoPlayerIOS.mm 文件中的-(voID) setURL:(int)vIDeoSource :(std::string &)vIDeoUrl函数中的
if (vIDeoSource == 1) {
self.movIEPlayer = [[MPMovIEPlayerController alloc] initWithContentURL:[NSURL URLWithString:@(vIDeoUrl.c_str())]];
self.movIEPlayer.movIESourceType = MPMovIESourceTypestreaming;
} else {
Nsstring *path = [UIVIDeoVIEwWrapperIos fullPathFromrelativePath:@(vIDeoUrl.c_str())];
self.movIEPlayer = [[MPMovIEPlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:path]];
self.movIEPlayer.movIESourceType = MPMovIESourceTypefile;
}
改为
if (vIDeoSource == 1) {
self.movIEPlayer = [[MPMovIEPlayerController alloc] initWithContentURL:[NSURL URLWithString:@(vIDeoUrl.c_str())]];
self.movIEPlayer.movIESourceType = MPMovIESourceTypestreaming;
} else {
Nsstring *path =[[NSBundlemainBundle]pathForResource:@(vIDeoUrl.c_str())ofType:nil];
self.movIEPlayer = [[MPMovIEPlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:path]];
self.movIEPlayer.movIESourceType = MPMovIESourceTypefile;
}
没有修改cocos2dx源码前视频都可以播放,后来就不知道怎么不能够播放了报上面的错误。
不过修改之后就可以播放啦
参考http://blog.csdn.net/realhector/article/details/24580781
总结以上是内存溢出为你收集整理的MPMoviePlayerViewController或MPMoviePlayerController播放本地视频报错:_itemFailedToPlayToEnd: {kind = 1;new =全部内容,希望文章能够帮你解决MPMoviePlayerViewController或MPMoviePlayerController播放本地视频报错:_itemFailedToPlayToEnd: {kind = 1;new =所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)