我想播放从 iPad 应用程序上传到服务器的视频,但是当屏幕加载时它会出错:
一个 AVPlayerItem 不能与多个 AVPlayer 实例关联
我正在使用以下代码:
-(void)playVideo{
NSURL *url = [NSURL URLWithString:@"http://celeritas.com.pk/emrapp/test.mp4"];
MPMoviePlayerViewController *mp = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:mp];
mp.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
[self presentMoviePlayerViewControllerAnimated:mp];
[mp release];
NSLog(@"Successfully playing thanks");
}
-(void)playbackFinishedCallback:(NSNotification *)notification{
MPMoviePlayerController *movie = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:movie];
[movie release];
}