0

As part of an iOS application we are trying to make, we would like a very small part of our application to keep running is the background, and save the names of the tracks the iPod is playing, and/or send them to our server.

So basically we want to register an event listener that tells our app when the iPod application plays a track, even if our app is in the background.

Is this possible? I have been digging around in the documentation and haven't found much useful.

Thanks!

Mina Almasry
  • 173
  • 1
  • 2
  • 12

1 Answers1

3

You can get the current playing song and just add them to an array of string by getting the names On iPhone: Find out what song is currently playing? (in the iPod music player)

EDIT: Better answer in this link

EDIT 2:

There's this link http://www.iphonedevsdk.com/forum/iphone-sdk-development/45438-different-sound-volumes-mpmusicplayer-system-sounds.html

A bit down he talks about some methods which gets invoked on song changes

- (void)handleNowPlayingItemChanged:(id)notification {
    MPMediaItem *currentItem = self.musicPlayer.nowPlayingItem;
    self.songLabel.text   = [currentItem valueForProperty:MPMediaItemPropertyTitle];
    self.artistLabel.text = [currentItem valueForProperty:MPMediaItemPropertyArtist];
}

hope this helps.

Community
  • 1
  • 1
La bla bla
  • 8,558
  • 13
  • 60
  • 109
  • Thanks! This solves the retrieving the name of the track. But since we want to do this from the background, is there a way to register an event listener that gets notified when the iPod plays a song? – Mina Almasry Apr 27 '12 at 22:53