AVPlayerItem error: operation stopped

I want to play YouTube videos using AVPlayer.

Here is my code:

let playerItem = AVPlayerItem(asset: AVAsset(url:URL(string: "https://www.youtube.com/watch?v=xxxxxxxxx")!))
player = AVPlayer(playerItem : playerItem)
playerLayer = AVPlayerLayer(player: player)
playerLayer.frame = self.view.bounds
player.play()

AVPlayerItemStatus goes to the error with this error:

Error Domain=AVFoundationErrorDomain Code=-11850 "Operation Stopped" UserInfo={NSUnderlyingError=0x1702443e0 {Error Domain=NSOSStatusErrorDomain Code=-12939 "(null)"}, NSLocalizedFailureReason=The server is not correctly configured., NSLocalizedDescription=Operation Stopped}

Can someone help me with this?

PS: When I change AVPlayerto AVQueuePlayer, it works!

+4
source share

Source: https://habr.com/ru/post/1663500/


All Articles