I have this code in a very simple, single view Swift application in my ViewController:
ViewController
var audioPlayer = AVAudioPlayer() @IBAction func playMyF
Important that AvPlayer is class member and not in the given function, else it goes out of scope... :)