قالب وردپرس درنا توس
Home / IOS Development / ios – MPMusicPlayerController and using Private API to get the current queue

ios – MPMusicPlayerController and using Private API to get the current queue



There is an answer to this question: iOS – get programmatic queue of objects that are currently playing, describing how to do this, but I try that method and it doesn't work. Here is my code:

    la nummerOfItems = player.value (forKey: "numberOfItems") as! int
for i in 0 .. <numberOfItems {

if la mediaItem = MPMusicPlayerController.systemMusicPlayer.perform (Selector ("nowPlayingItemAtIndex:"), with: i)?. takeUnretainedValue () as? MPMediaItem {
let songObject = mediaItem.value (forKey: "propertyValues") like! NSObject
print (songObject.value (forKey: "title"))
print (mediaItem.title)
print (mediaItem.value (forKey: "title"))
print (mediaItem.value (forProperty: MPMediaItemPropertyTitle))
}
}

All 4 print declarations are zero. It is worth noting that it can actually throw the item as an MPMediaItem, and the songObject variant actually prints as an MPModelSong. The runtime headers indicate that there is a property on MPModelSong objects "title" (found here: https://github.com/nst/iOS-Runtime-Headers/blob/master/Frameworks/MediaPlayer.framework/MPModelSong.h)[1

9659004] Whatever, everything prints zero. Any idea which direction should I head from here?


Source link