Query Now Playing

PDF for offline use
Sample Code:
Related SDKs:

Let us know how you feel about this

Translation Quality


0/250

Get information about the song playing in the Music Player.

Recipe

  1. Add a reference to MediaPlayer
using MediaPlayer;
  1. Create a new MPMusicPlayerController
MPMusicPlayerController MyPlayer = new MPMusicPlayerController();
  1. To get information about the currently playing song, use the NowPlaying property:
MPMediaItem Now = MyPlayer.NowPlayingItem;

UIImage MyArtwork = Now.Artwork.ImageWithSize (new CGSize(100, 100));

Track.Text = Now.Title;
Artist.Text = Now.Artist;
Album.Text = Now.AlbumTitle;
Lyrics.Text = Now.Lyrics;
Artwork.Image = MyArtwork;

Additional Information

The MediaPlayer API does not run properly on a simulator. Always test on a device.

Xamarin Workbook

If it's not already installed, install the Xamarin Workbooks app first. The workbook file should download automatically, but if it doesn't, just click to start the workbook download manually.