How to get Duration from AVPlayer (Not AVAudioPlayer)?

前端 未结 7 1092
隐瞒了意图╮
隐瞒了意图╮ 2020-12-13 03:43

I would like to make a UISlider(scrubber) for my AVPlayer. But since this is not an AVAudioPlayer, it doesn\'t have a built in duration. Any suggestion on how to create the

7条回答
  •  时光说笑
    2020-12-13 04:17

    For Swift to get duration in seconds

    if let duration = player.currentItem?.asset.duration {
        let seconds = CMTimeGetSeconds(duration)
        print("Seconds :: \(seconds)")
    }
    

提交回复
热议问题