Playback rate not working on ios YouTube YTPlayerView

纵然是瞬间 提交于 2019-12-11 16:27:42

问题


I'm successfully playing a video retrieved from YouTube API in YTPlayerView This is the video: https://www.youtube.com/watch?v=sV1e-iSo5As Viewing directly in Chrome, I'm able to change player rate to various rates (0.25, 0.5 etc) However when I attempt one of these rates, during playback in my App using, say: setPlaybackRate(0.5), nothing changes (I've tried this both pre, and during playback)

Calling availablePlaybackRates() returns nil (I've tried this both pre, and during playback)

I have attempted this both on physical devices (iPhone ios10.3 + iPad ios10.3) as well as on various simulators. I have also tried with various other YouTube videos - same result.

Is it not possible to change playback rates in YTPlayerView, or is there some pre-setup required?

Relevant Code

func ytPlayerViewLoad(vid: String) {
    playerView.load(withVideoId: vid, playerVars: ["playsinline" : 1])
    playerView.webView.allowsInlineMediaPlayback = true
}
@IBAction func speedHalf(_ sender: Any) {
    if playerView.availablePlaybackRates() == nil {
        print("Do'h - no playback rates available")
    } else {
        print("Yay - playback rates available")
    }
    playerView.setPlaybackRate(0.5)
}

I'm starting to experiment with bypassing YTPlayerView and using UIWebView directly - passing in javascript to change player rate - but not getting far - but if anyone knows of an example of this that would be great! THanks

来源:https://stackoverflow.com/questions/45816248/playback-rate-not-working-on-ios-youtube-ytplayerview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!