The previous post had errors I didn't notice. Sorry.
I have this to play a piece of music
@IBAction func play(_ sender: AnyObject) {
audioPlayer.play()
What I want to do is have the music play while the button is pressed and stop when it is released.
I have connected both touchDown and touchUpInside to the IBAction.
I have tried using many combinations of
if // touchDown {
audioPlayer.play()
} else if // touchUpInside {
audioPlayer.stop()
} else {
}
but I cant find a way to have the method recognise the touchDown and touchUpInside actions.
Can this be done?