I want to play a youtube video with 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()
The AVPlayerItemStatus
passes to failed 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 anybody help me through this?
PS: When I change AVPlayer
to AVQueuePlayer
it works!