swift - Play sound with AKAudioPlayer - iOS -
how declare akaudioplayer ? i'm using audiokit lib , need play .wav file change file button. import uikit import audiokit class viewcontroller: uiviewcontroller { let file = nsbundle.mainbundle().pathforresource("song", oftype: "wav") let song = akaudioplayer(file!) // <--- error = instance member 'file' cannot used on type override func viewdidload() { super.viewdidload() audiokit.output = song audiokit.start() song.play() } @ibaction func btn(sender: anyobject) { song.replacefile("newfile") song.play() } } this fast solution problem. can done better @ least can idea. first try make new class function play file , function reload new replacement file this. class playmymusic { var songfile = nsbundle.mainbundle() var ...