遇到MPMoviePlayerController问题。当我尝试加载视频时,我只是在导航栏中获得活动指示器并显示加载。您可以在底部看到控制器,因此控制器不会加载视频。我已将链接复制到浏览器中,视频播放正常。我正在使用iTunes中已经启动的应用程序中的相同代码,我只是在改进它。因此,当我点击iTunes中应用程序中的视频时,视频工作正常。不知道现在发生了什么是我的代码:
-(void)loadVideo {
NSURL *url = [NSURL URLWithString:self.videoUrl];
NSLog(@"url %@", self.videoUrl);
self.movie = [[MPMoviePlayerController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.movie];
self.movie.controlStyle = MPMovieControlStyleDefault;
self.movie.shouldAutoplay = YES;
[self.view addSubview:self.movie.view];
[self.movie setFullscreen:YES animated:YES];
}
- (void) moviePlayBackDidFinish:(NSNotification*)notification {
MPMoviePlayerController *player = [notification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
if ([player
respondsToSelector:@selector(setFullscreen:animated:)])
{
[player.view removeFromSuperview];
}
}
为什么会发生这种情况?
答案 0 :(得分:0)
解决了这个问题。当我使用属性self.videoUrl时,它是一个包含@""的字符串。仍然附着。我需要从字符串中删除它,所以只剩下url。