Showing posts with label [Xcode] Media. Show all posts
Showing posts with label [Xcode] Media. Show all posts

Friday, May 25, 2012

How to play music in your app


n this tutorial we will have a look at how to use MediaPlayer framework to play music from your app. To begin with we need to#import <MediaPlayer/MediaPlayer.h>. There are three core classes that we will work with.
MPMusicPlayerControllerThere are two types of MPMusicPlayerController
  • Application music player ([MPMusicPlayerController applicationMusicPlayer])that plays music just in your app and does not affect the in-built iPod
  • iPod music player ([MPMusicPlayerController iPodMusicPlayer]) that employs the in-built iPod to play music – the music can be controlled in the iPod app and remains playing even after you quit your app
MPMusicPlayerController methods are quite self-explanatory:
  • - setQueueWithQuery: and - setQueueWithItemCollection are used to set playback queue with query (see below)
  • - play, – pause, – stop, – beginSeekingForward, – beginSeekingBackward, – endSeeking, – skipToNextItem, – skipToPreviousItem, – skipToBeginning are all used to control the player
  • currentPlaybackTime, nowPlayingItem, playbackState, repeatMode, shuffleMode, volume are all properties of the player that you can use to change the behavior or display different attributes

Popular Posts