60442

How to detect a song playing by iPod

Question:

Is it possible programmatically find out a song details of iPod library if my app allows playing background iPod music? some like:

start "My app" if (iPod music playing) { song.details == playing.music.details" }

I don't even have no idea how to determinate if is any song is playing by iPod. Any idea?

Answer1:

It kinda easy:

MPMusicPlayerController *musicPlayer = [MPMusicPlayerController iPodMusicPlayer]]; NSLog(@"Playing %@", [[musicPlayer nowPlayingItem] valueForProperty:MPMediaItemPropertyArtist]);

Answer2:

See the <a href="http://developer.apple.com/library/ios/#documentation/MediaPlayer/Reference/MediaPlayer_Framework/_index.html" rel="nofollow">Media Player Framework Reference</a>:

<blockquote>

"This framework...gives your application access to the iPod library."

</blockquote>

Recommend

  • Is passing an uninitialized variable to another function UB [closed]
  • how to determinate destination MAC address
  • Python 3 - How do I use tkinter progressbar with a bat file?
  • jPlayer 2.2.0: display track title in separate div on page load
  • How to upload video to Vimeo through their api?
  • node expressjs - parsing a multipart/form-data POST data using body-parser middleware
  • Need to selectively remove newline characters from a file using unix (solaris)
  • Any disadvantages of using JQTouch/Phonegap over Android API?
  • Scroll down whole browser window
  • How to get a list of songs, artists, albums on WP7 devices?
  • R matching more than 2 conditions and return the response value
  • BackgroundMediaPlayer set Uri source of Media library item
  • Is it possible to control programs with Javascript?
  • Error while re-opening sound file in python
  • Build Matrix of Comparisons in SQl Server
  • Specify HTTPS for custom WCF Binding
  • Android changing fragment order inside FragmentPagerAdapter
  • Jquery popup on mouse over of calendar control
  • How do I get HTML corresponding to current DOM tree?
  • Record samples being played with OpenAL
  • How to create a file in java without a extension
  • Google Custom Search with transparent background
  • Android fill_parent issue
  • Repeat a vertical line on every page in Report Builder / SSRS
  • Read text file and split every line in MSBuild
  • C# - Serializing and deserializing static member
  • How would I use PHP exceptions to define a redirect?
  • Java applet as stand-alone Windows application?
  • How to apply VCL Styles to DLL-based forms in Inno Setup?
  • retrieve vertices with no linked edge in arangodb
  • using conditional logic : check if record exists; if it does, update it, if not, create it
  • python regex in pyparsing
  • Error creating VM instance in Google Compute Engine
  • Android Google Maps API OnLocationChanged only called once
  • How can I remove ASP.NET Designer.cs files?
  • python draw pie shapes with colour filled
  • Is there any way to bind data to data.frame by some index?
  • How can i traverse a binary tree from right to left in java?
  • How can I use threading to 'tick' a timer to be accessed by other threads?