Check if music is playing

I use avaudioplayer to play my own music in my application. is it possible to check if music is playing from avaudioplayer?

+6
source share
1 answer

Use the play property, i.e.:

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

Also see the AVAudioPlayer class link .

A class reference indicates that you should not poll this property. If you want to know if a song has ended, use AVAudioPlayerDelegate . The audioPlayerDidFinishPlaying:successfully: function audioPlayerDidFinishPlaying:successfully: will audioPlayerDidFinishPlaying:successfully: you when the audio player finishes playing sound.

+9
source

Source: https://habr.com/ru/post/885538/


All Articles