An AVPlayerItem cannot be associated with more than one instance of AVPlayer'

前端 未结 5 1490
广开言路
广开言路 2021-02-05 08:16
-(IBAction)play:(id)sender
{

    thumbImageView.alpha=0.0;

    NSString *stringvideo=[NSString stringWithFormat:@\"http://streaming-service\",[[NSUserDefaults standard         


        
相关标签:
5条回答
  • 2021-02-05 08:29

    It might be a problem with MovieSourceType; you are playing a local file but using MPMovieSourceTypeStreaming; just modify the type and try again

    0 讨论(0)
  • 2021-02-05 08:40

    Had same issue, try setting ContentURL after Setting the SourceType like below,

    moviePlayerController_ = [[MPMoviePlayerViewController alloc] init];
    moviePlayerController_.movieSourceType = MPMovieSourceTypeStreaming;
    [moviePlayerController_.moviePlayer setContentURL:url];
    

    Source: devforums.apple.com/message/467199

    0 讨论(0)
  • 2021-02-05 08:47

    i have used moviePlayerController.movieSourceType = MPMovieSourceTypeUnknown its works for me.. try it..

    0 讨论(0)
  • 2021-02-05 08:50

    First you have to inform to player the source type ofter you set that content of video file; like this

    Here is two types of urls; if the url is like this you write this function

     NSString *aStr=@"http://www.my url like this.com/video/videos/review/Michale JACKSON  AUDIENCE Comment.mp4";   
    
    aStr = [aStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    

    or (second one)

    NSString *aStr=@"http://www.normal url.com/video.mp4"
    
    // after add your url string to this url
    
    NSURL *url=[NSURL URLWithString:aStr];
    MPMoviePlayerViewController *MPlayer = [[MPMoviePlayerViewController alloc]init];
    MPlayer.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
    [MPlayer.moviePlayer setContentURL:url];
    [self presentMoviePlayerViewControllerAnimated:MPlayer];
    
    0 讨论(0)
  • 2021-02-05 08:52

    Not a direct answer to the question, but if you get this error after trying to update contentURL, calling stop() before solves the problem.

    moviePlayerController.stop()
    moviePlayerController.movieSourceType = .File
    moviePlayerController.contentURL = newURL
    
    0 讨论(0)
提交回复
热议问题