Playback rate not working on ios YouTube YTPlayerV

2019-08-23 10:13发布

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

0条回答
登录 后发表回答