iPhone 3.0 操作系统应用程序在 iPhone 4.0 操作系统中运行时崩溃的视频
我在 iPhone 4.0 操作系统中播放视频时遇到崩溃问题。实际上,我已经使用基础 SDK 3.0 创建了应用程序,现在我只是将应用程序安装到 4.0 操作系统设备。
它不起作用...我已经调试了这个问题,发现在4.0操作系统中,苹果改变了播放视频的框架和方法。
任何人都可以帮助我如何克服这个问题。
这是我的代码,在 3.0 操作系统中运行良好。
-(void)play
{
NSBundle *bundle = [NSBundle mainBundle];
//NSString *path = [bundle pathForResource:@"Icon" ofType:@"png"];
NSString *path = [bundle pathForResource:@"loader" ofType:@"m4v"];
NSURL *url = [NSURL fileURLWithPath:path];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
moviePlayer.movieControlMode = MPMovieControlModeHidden;
[moviePlayer play];
}
提前致谢, 普拉格内什
I am having a crash issue while playing video in iphone 4.0 OS. Actually, I have created application with base SDK 3.0 and now i am just installing application to 4.0 OS device.
It is not working in that... I have debugged that issue and found that in 4.0 OS, apple change the framework and methods to play the video.
Any one help me how to overcome this issue.
Here is my code which is running fine in 3.0 OS.
-(void)play
{
NSBundle *bundle = [NSBundle mainBundle];
//NSString *path = [bundle pathForResource:@"Icon" ofType:@"png"];
NSString *path = [bundle pathForResource:@"loader" ofType:@"m4v"];
NSURL *url = [NSURL fileURLWithPath:path];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
moviePlayer.movieControlMode = MPMovieControlModeHidden;
[moviePlayer play];
}
Thanks in advance,
Pragnesh
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于iOS4,您需要使用MPMoviePlayerViewController。我发布了我的 工作代码示例在这里。
With iOS4, you need to use the MPMoviePlayerViewController. I posted my working code sample here.