Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

212
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda