如何从AVPlayer获取持续时间(不是AVAudioPlayer)? [英] How to get Duration from AVPlayer (Not AVAudioPlayer)?

查看:451
本文介绍了如何从AVPlayer获取持续时间(不是AVAudioPlayer)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的AVPlayer制作一个UISlider(擦洗器)。但由于这不是AVAudioPlayer,因此它没有内置的持续时间。有关如何创建滑块以进行快进,快退和播放进度的任何建议?

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 Slider for fast forward, rewind and progress of the playback?

我在AVPlayer上阅读了doc,它有一个内置的seekToTime或seekToTime:toleranceBefore:toleranceAfter:。我真的不明白。这会是我滑块的答案吗? AVPlayer还有addPeriodicTimeObserverForInterval:queue:usingBlock:,这是用于获取我的音轨的持续时间吗?有人能举例说明如何实现这段代码吗?我不是Apple的文档粉丝。这似乎很难理解。

I read the doc on AVPlayer, it has a built in seekToTime or seekToTime:toleranceBefore:toleranceAfter:. I don't really understand it. Would this be the answer for my slider? AVPlayer also has addPeriodicTimeObserverForInterval:queue:usingBlock:, is this for getting the duration of my track? Can someone give me an example on how to implement this code? I am not a fan of Apple's documentation. It seems very hard to understand.

推荐答案

self.player.currentItem.asset.duration

知道了!

这篇关于如何从AVPlayer获取持续时间(不是AVAudioPlayer)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆