如何将Youtube视频流式传输到AVPlayer?有没有办法可以获得视频的状态(缓冲,暂停,播放等)?
答案 0 :(得分:-1)
是的,您可以在AVPlayer上播放YouTube视频。 使用observer可以确定AVPLayer的状态。
例如:
let player = AVPlayer(URL: NSURL(string: "http://www.sample.com/movie.mov"))
if (player.rate != 0 && player.error == nil) {
println("playing")
}
NSNotificationCenter.defaultCenter().addObserverForName(
AVPlayerItemFailedToPlayToEndTimeNotification,
object: nil,
queue: nil,
usingBlock: { notification in
self.stop()
})