简体   繁体   English

应用此错误消息检查网络后,应用程序崩溃:AVPlayerItem无法与多个AVPlayer实例关联

[英]App crashes after checking network with this error message : An AVPlayerItem cannot be associated with more than one instance of AVPlayer

I'm getting this error mentioned in title while playing a video from internet. 从互联网播放视频时,标题中出现此错误。

- (void)viewDidLoad
{  
  NSString *urlAdress = [NSString stringWithFormat:@"http://www.dailymotion.com/video/x108t8t"];
  //NSString *urlAdress = [[NSBundle mainBundle] pathForResource:@"video8" ofType:@"mp4"];in this case video plays.
  NSURL *videoURL = [NSURL fileURLWithPath:urlAdress];
  self.mpvc = [[MPMoviePlayerViewController alloc] initWithContentURL:videoURL];  

  [[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlaybackDidFinish:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:nil];

  self.mpvc.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
  //when using file in resources use MPMovieSourceTypeFile,when online then streaming
  [self presentMoviePlayerViewControllerAnimated:mpvc];
  [super viewDidLoad];
}
//and here is moviePlaybackDidFinish method    
- (void)moviePlayBackDidFinish:(NSNotification *)notification
{
MPMoviePlayerController *theMovie = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
                                                name:MPMoviePlayerPlaybackDidFinishNotification
                                              object:theMovie];
[theMovie stop];
[theMovie.view removeFromSuperview];
 NSLog(@" playback finish Called......");

}

this is whole code. 这是完整的代码。 i have went through most of tutorials,stackoverflow questions but could not get a single solution 我经历了大多数教程,stackoverflow问题,但无法获得一个解决方案

Your URL is not correctly created for the case you quoted. 您所引用的情况未正确创建您的URL。

You are trying to play a remote stream, hence the URL needs to be a remote one. 您正在尝试播放远程流,因此URL必须是远程流。

Local file URLs are created using fileURLWithPath . 本地文件URL是使用fileURLWithPath创建的。 Remote URLs are created using URLWithString . 远程URL是使用URLWithString创建的。

Local File URL 本地文件URL

NSURL *videoURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"video8" ofType:@"mp4"]];

Remote URL 远端网址

NSURL *videoURL = [NSURL URLWithString:@"http://www.dailymotion.com/video/x108t8t"];

well this question seems a lot on stack overflow, i got a solution to this. 好了,这个问题在堆栈溢出上似乎很多,我对此有了解决方案。 most of the people facing same issue have right code but only problem is we forget to add dailymotion,vimeo frameworks. 面对相同问题的大多数人都有正确的代码,但唯一的问题是我们忘记添加dailymotion,vimeo框架。 since they provide their own framework sdks you can download them from links below and add them to your projects. 由于它们提供了自己的框架SDK,因此您可以从下面的链接下载它们并将其添加到您的项目中。

http://www.dailymotion.com/doc/api/sdk-objc.html http://www.dailymotion.com/doc/api/sdk-objc.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AVPlayerItem不能与多个AVPlayer实例相关联 - An AVPlayerItem cannot be associated with more than one instance of AVPlayer' nsinvalidargumentexception'reason'avplayeritem无法与多个avplayer实例关联' - nsinvalidargumentexception' reason 'an avplayeritem cannot be associated with more than one instance of avplayer' 在检查iphone中的网络可达性后app崩溃了? - app crashes after checking network reachability in iphone? 应用程序崩溃,并将错误消息发送到解除分配的实例 - app crashes with error message sent to deallocated instance AVPlayerItem 因 AVStatusFailed 和错误代码“无法解码”而失败 - AVPlayerItem fails with AVStatusFailed and error code “Cannot Decode” 多个委托监听uisearchbar的实例 - more than one delegate listen to an instance of uisearchbar 无法将多个UIBarButtonItem添加到RightBarButtonItems - Cannot add more than one UIBarButtonItem to RightBarButtonItems 可以将多个应用程序合并为一个整体应用程序吗? - Can more than one app be combined into one overall app? 将更多行加载到自定义表后,iPhone应用程序崩溃 - iphone app crashes after loading more row into a custom table 一个应用中的移动广告超过2个或更多(Iphone,Android和Window) - Mobile ads more than 2 or more in one app (Iphone & android & window)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM