MPMoviePlayercontroller在iphone SDK 4中不工作?-需要帮助
直到昨天,我的MPMovieController在iphonesdk3中运行良好。但是昨天我升级了SDK tiiphone SDK 4我的movieplayer停止工作时,它在下面一行给了我一个弃用警告(他们已经弃用了很多方法) 我的全部代码如下:MPMoviePlayercontroller在iphone SDK 4中不工作?-需要帮助,iphone,mpmovieplayercontroller,deprecated,ios4,Iphone,Mpmovieplayercontroller,Deprecated,Ios4,直到昨天,我的MPMovieController在iphonesdk3中运行良好。但是昨天我升级了SDK tiiphone SDK 4我的movieplayer停止工作时,它在下面一行给了我一个弃用警告(他们已经弃用了很多方法) 我的全部代码如下: NSURL *fileURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@/videos/%@",[[NSUserDefaults standardUserDefaults] objec
NSURL *fileURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@/videos/%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"SERVICE_URL"]
,customObject.movieURL]];
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
if (mp)
{
// save the movie player object
self.moviePlayer = mp;
moviePlayer.movieControlMode = MPMovieControlModeDefault;
[mp release];
// Apply the user specified settings to the movie player object
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(myMovieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
// Play the movie!
[self.moviePlayer play];
}
请告诉我要替换哪个方法而不是不推荐的方法,或者应该做一些不同的事情
谢谢,我今天早上刚刚使用了MPMoviePlayerController,该代码运行良好(仅在iPad模拟器上测试)
所以我们现在必须手动添加视图,然后再删除?我没有添加任何tmpView,所以它不起作用。有必要吗。因为以前它在没有任何调整的情况下工作。@cear:你使用的是iphonesdk4吗?@hib:是的,我使用的是iOS4,而不是,你不需要任何tmpView。只需设置视图和addSubview的框架:这里是对这个延迟的唯一引用:但它是关于远程流的。无论如何,我还没有尝试,但是您可以尝试预播放视频并在MPMoviePlayerLoadStateDidChangeNotification上暂停它(在验证之后),然后当用户点击“播放按钮”时再次播放。这是一个黑客,我知道。。。
NSURL *fileURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@/videos/%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"SERVICE_URL"]
,customObject.movieURL]];
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
if (mp)
{
// save the movie player object
self.moviePlayer = mp;
moviePlayer.movieControlMode = MPMovieControlModeDefault;
[mp release];
// Apply the user specified settings to the movie player object
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(myMovieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
// Play the movie!
[self.moviePlayer play];
}
NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"video.mp4" ofType:nil];
NSURL *url = [NSURL fileURLWithPath:urlStr];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[self.view addSubview:moviePlayer.view];
moviePlayer.view.frame = CGRectMake(50, 50, 200, 200);
[moviePlayer play];