I would like to dispose all loaded audio except one, all at once in the end of the scene. Possible?
Is there is any way to check or audio file is loaded when audio handle is lost?
local allMusic = { { id = "song1.mp3"}, { id = "song2.m4a"}, { id = "song3.mp3"} } audio.reserveChannels(1) \_G.currentSong = audio.loadStream(allMusic[1].id) audio.play(currentSong , {channel=1, loops=-1}) for i = 1, #allMusic do local btn = display.newRect(200, 50+(i\*100), 50, 50) btn:addEventListener("touch", function(event) if event.phase == "began" then audio.stop(1) --audio.dispose(currentSong) --currentSong = nil \_G.currentSong = audio.loadStream(allMusic[i].id) audio.play(currentSong , {channel=1, loops=-1}) end end) end --later in code local function gotoNextScene() --dispose all loaded audio but not currently playing. end
Edit: I am wondering do you guys use audio.loadSream as a global?