2010-06-28 68 views
5

我开发了在iPad和iPhone上运行的通用应用程序。我在这里使用MPMoviePlayerController的一个组件。iOS 4 + MPMoviePlayerController

现在iOS4发布了,今天我得到了一个关于由于此MPMoviePlayerController崩溃导致应用程序拒绝的坏消息。

iDemoPlayer= [[MPMoviePlayerController alloc] initWithContentURL:aUrl]; 
[iDemoPlayer play]; 

这是我的src播放视频的代码。

在iPhone OS 4.0的发布,我发现

"If you link a Universal application against iPhone SDK 3.2, you must be prepared to embed the movie player view in your interface when running on iOS 4 and later"

裁判

http://developer.apple.com/iphone/library/releasenotes/General/RN-iPhoneSDK-4_0/index.html

你们能帮助我,我需要什么更新用做这样它会再次接受! !!!!!

感谢,

萨加尔

回答

5

唉,Symbian的变量命名约定。

if ([MPMoviePlayerController instancesRespondToSelector:@selector(view)]) { 
    // Running on 3.2+ 
    iDemoPlayer2 = [[MPMoviePlayerViewController alloc] initWithContentURL:aUrl]; 
    // Assuming self is a UIViewController 
    [self presentMoviePlayerViewControllerAnimated:iDemoPlayer2]; 
    // This line might be needed 
    [self.moviePlayer play]; 
} else { 
    iDemoPlayer= [[MPMoviePlayerController alloc] initWithContentURL:aUrl]; 
    [iDemoPlayer play]; 
} 
2

如果您想继续使用OS 4.0之前的全屏播放器,请按照以下步骤修改您的代码。您可能以前有两行看起来像:

MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:someURL]; 
[moviePlayer play];

您现在需要放置电影播放器​​的视图。我们假设这是一个UIViewController,并已低于self.view使用:

MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:someURL]; 

if ([moviePlayer respondsToSelector:@selector(view)]) { 
    moviePlayer.controlStyle = MPMovieControlStyleFullscreen; 
    [moviePlayer.view setFrame:self.view.bounds]; 
    [self.view addSubview:moviePlayer.view]; 
} 

[moviePlayer play];

你的电影播放器​​,现在应该继续在OS 4.0和以前类似的行为。

+0

它抛出这个错误: - [MPMoviePlayerControllerOld setControlStyle:]:无法识别的选择发送到实例0x8029340' – 2010-09-04 06:22:47

+0

它抛出了同样的错误给我:(请您提供一下进一步的信息? – Sindico 2010-12-14 21:49:38