Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

210
Views
MPMusicPlayerController and using Private API to get current queue

There is an answer on this question: iOS - get programatically queue of items currently playing that describes how to do this, however I am trying that method and it does not work. Here is my code:

  let numberOfItems = player.value(forKey: "numberOfItems") as! Int
  for i in 0..<numberOfItems {

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

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

No matter what, everything prints nil. Any idea what direction I should head from here?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!