I want to make it so that a button can be clicked, which will start repeatedly playing a system sound over and over (without overlapping the sounds) until the button is clicked again - so essentially, the button will toggle the repeated playing of an audio services system sound on/off.
If anyone would know how to do this I would greatly appreciate it.
Thanks
To do this use an
AVAudioplayerwith infinite repeat, and then pause/play it when button is pressed. First make a audioPlayer variable, outside of any function:Then initialise the audioPlayer inside of viewDidLoad:
Then inside a function linked to your button, in my case I named that function buttonPressed: