nsinvalidargumentexception' reason 'an avp

2019-07-12 00:57发布

问题:

I am using

MPMoviePlayerController

for play video and in this I used custom seek bar to jump video. but when I continuously do the seeking forward and rewind then application crashed and throw below error:

nsinvalidargumentexception' reason 'an avplayeritem cannot be associated with more than one instance of avplayer'

So please suggest.

Thanks

回答1:

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



回答2:

Had same experience. realized movieSourceType was set incorrectly. For example, movieSourceType was set to MPMovieSourceTypeStreaming when it should have been MPMovieSourceTypeFile for a movie embedded in the bundle.



回答3:

I had the same problem and in my case the problem is that I couldn't tell if the movie is a file or a stream (the URL doesn't tell), so I set it to MPMovieSourceTypeUnknown and that also solved the problem. It has that value by default but if you start playing a movie of either type, it internally changes the type to either stream or file and if you now change the URL without setting the correct type or manually setting type back to MPMovieSourceTypeUnknown, you'll get an exception.