Programmatically reading and changing elapsed time of music(iPod's media library)?
-
21-09-2019 - |
Question
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?
Solution
By calling beginGeneratingPlaybackNotifications
on the MPMusicPlayerController
and registering for MPMusicPlayerControllerPlaybackStateDidChangeNotification
notifications, you will receive periodic updates when the playback state has changed. In the handler for that notification you can then get the currentPlaybackTime
from the MPMusicPlayerController
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow