Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting if music is playing?

My app involves music(iPodMusic), and there is a UISwitch toggling play/pause. My goal is to be able to detect if music is playing, so that therefore the play/pause switch can say 'play' when music is playing and 'pause' if it isn't.

like image 480
Flafla2 Avatar asked Feb 16 '10 16:02

Flafla2


2 Answers

if ([[MPMusicPlayerController iPodMusicPlayer] playbackState] == MPMusicPlaybackStatePlaying) ...
like image 145
Ole Begemann Avatar answered Sep 18 '22 17:09

Ole Begemann


If the music is from your own app, check AVAudioPlayer's playing property.

If the music is from iPod, check MPMusicPlayerController's nowPlayingItem or playbackState property.

like image 40
kennytm Avatar answered Sep 22 '22 17:09

kennytm