如何设置音乐播放器中的音乐播放滑块
我在我的应用程序中创建了一个具有上一个和下一个功能的音乐播放器。我想实现歌曲播放滑块。怎么办?
i created a music player with previous and next functionality in my app.i want to impliment song playback slider. how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
UISlider
将 maxValue 设置为当前播放歌曲的持续时间(以秒为单位),将 minValue 设置为 0。假设您使用的是
MPMusicPlayerController
,请使用currentPlaybackTime
获取播放曲目的当前时间并使用该值每秒更新滑块Use a
UISlider
setting the maxValue to the current playing song duration (in seconds) and the minValue to 0.Assuming that you're using an
MPMusicPlayerController
use thecurrentPlaybackTime
to get the current time of the playing track and use that value to update the slider each second