Travis Kirton

Audio Player

This example shows how you can create and play an audio sample. Creating a player is simple:

let ap = AudioPlayer("C4Loop.aif")

Like a movie, you have to specify the file extension of an audio player.

In Memory

You need to create an audio player property outside the scope of a method. If you don’t the app won’t keep the player in memory and it will disappear without ever playing.

class WorkSpace: CanvasController {
    let audioPlayer = AudioPlayer()
    override func setup() {
        //Playback here, or in another method...


let audioPlayer = AudioPlayer("C4Loop.aif")!

override func setup() {
    audioPlayer.loops = true