开发者

An AVPlayerItem can occupy only one position in a player's queue at a time

开发者 https://www.devze.com 2023-03-18 19:06 出处:网络
Im getting this error when trying to play a video from my temp directory: NSString *tmpDir = [NSTemporaryDirectory() stringByAppendingString:@\"/\"];开发者_运维百科

Im getting this error when trying to play a video from my temp directory:

NSString *tmpDir = [NSTemporaryDirectory() stringByAppendingString:@"/"];开发者_运维百科
NSString *url = [tmpDir stringByAppendingString:videoToPlay];

MPMoviePlayerController *player =
[[MPMoviePlayerController alloc]
 initWithContentURL:[NSURL fileURLWithPath:url]];

Why am i getting this error "An AVPlayerItem can occupy only one position in a player's queue at a time."

Isnt that code correct? Am i missing something simple?


I tried various solutions provided in apple dev forums. In my case what worked was just changing the source type from streaming to unknown:

// player.movieSourceType = MPMovieSourceTypeStreaming;

  player.movieSourceType = MPMovieSourceTypeUnknown;


Use following statement to avoid such error. Please keep in mind that, THE sdk that you are using is under NDA.

[self.mPlayer.moviePlayer setControlStyle:MPMovieControlStyleDefault];


try to check control style and source type. Im getting this error ,and when change source type to unknow(auto detect,maybe) It goes right.


I got this because i had invalid parameters for movieSourceType, i thought you were supposed to put a MPMovieMediaTypeMask in there (video/audio,etc) but instead you are supposed to put a MPMovieSourceType. Fixing that made it work for me


This happened to me when trying to use replaceCurrentItem on my AVQueuePlayer.

Apple states you should NOT use this method with AVQueuePlayer: https://developer.apple.com/documentation/avfoundation/avplayer/1390806-replacecurrentitemwithplayeritem

Instead I'm testing removeAllItems() and insert(AVPlayerItem, after: AVPlayerItem?) with a nil value for AVPlayerItem.

iOS12 Swift 5.

0

精彩评论

暂无评论...
验证码 换一张
取 消