简体   繁体   English

如何设置 tvos 应用程序 avplayer 的速度,基于用户单击 2x,3x 等按钮

[英]How to set speed of avplayer of tvos application, based on user clicking the button like 2x,3x

Iam working with AVPlayer of tvos application,making the speed of the avplayer when user clicks button 3x (self.player.rate = 3.0).我正在使用 tvos 应用程序的 AVPlayer,使用户单击按钮 3 倍时 avplayer 的速度(self.player.rate = 3.0)。 But rate of playing the video is not changing it is playing at normal rate.但是播放视频的速度没有改变,它以正常速度播放。 is rate property is not work in tvos application.是 rate 属性在 tvos 应用程序中不起作用。 can any help me how to set the speed of the avplayer.任何人都可以帮助我如何设置 avplayer 的速度。

Here is my setup code.这是我的设置代码。

func setUpPlayer(videourl:String) {
    playerItem = AVPlayerItem.init(url: URL(string: videourl)!)
    player = AVPlayer(playerItem: playerItem)
    self.player.actionAtItemEnd = AVPlayerActionAtItemEnd.none
    let av = AVPlayerViewController()
    av.player = player
    av.view.frame = CGRect(x: 0, y: 0, width: 1920, height: 1080)
    av.showsPlaybackControls = true
    self.addChildViewController(av)
    self.view.addSubview(av.view)
    if isfromspeed {
        self.player!.rate = 3.0
    }
    player.play()
}

From the docs ...文档...

A value of 0.0 pauses the video, while a value of 1.0 plays the current item at its natural rate.值 0.0 暂停视频,而值 1.0 以自然速率播放当前项目。 Rates other than 0.0 and 1.0 can be used if the associated player item returns true for the AVPlayerItem properties canPlaySlowForward or canPlayFastForward.如果关联的播放器项目为 AVPlayerItem 属性 canPlaySlowForward 或 canPlayFastForward 返回 true,则可以使用 0.0 和 1.0 以外的速率。 Negative rate value ranges are supported if the player item returns true for the canPlayReverse, canPlaySlowReverse, and canPlayFastReverse properties.如果播放器项目为 canPlayReverse、canPlaySlowReverse 和 canPlayFastReverse 属性返回 true,则支持负速率值范围。

You will need to confirm that both the current media and platform supports values other than 0.0 or 1.0您需要确认当前媒体和平台都支持0.01.0以外的值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM