Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

check if music is played [closed]

i use avaudioplayer to play own music in my app. is there a possibility to check if music from the avaudioplayer is playing?

like image 263
Leon Avatar asked Apr 08 '11 23:04

Leon


1 Answers

Use the playing property, i.e.:

AVAudioPlayer *audioplayer;
if(audioplayer.playing){
   //do what you want here
}

Also refer to the class reference of AVAudioPlayer.

The class reference states you shouldn't poll this property though. If you want to find out if a song has finished playing, use an AVAudioPlayerDelegate. The audioPlayerDidFinishPlaying:successfully: function will inform you when the audio player finished playing audio.

like image 174
Tovi7 Avatar answered Oct 13 '22 06:10

Tovi7