以编程方式读取和更改音乐的已播放时间(iPod 的媒体库)?
我正在创建一个音乐应用程序,非常类似于标准音乐应用程序。现在,我对他们如何使用 UISlider 读取和更改歌曲的已播放时间感到困惑。如何读取和更改歌曲的已播放时间?
I am creating a music application, much like the standard music app. Now, I am befuddled on how they were able to read and change the elapsed time of a song using a UISlider. How is it possible to read and change the elapsed time of a song?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过在
MPMusicPlayerController
上调用beginGeneratePlaybackNotifications
并注册MPMusicPlayerControllerPlaybackStateDidChangeNotification
通知,您将在播放状态发生更改时收到定期更新。在该通知的处理程序中,您可以从MPMusicPlayerController
获取currentPlaybackTime
。By calling
beginGeneratingPlaybackNotifications
on theMPMusicPlayerController
and registering forMPMusicPlayerControllerPlaybackStateDidChangeNotification
notifications, you will receive periodic updates when the playback state has changed. In the handler for that notification you can then get thecurrentPlaybackTime
from theMPMusicPlayerController
.