Dispose Audio

 It’s simple to rewind and stop all audio, but how to dispose of all audio without having to name each of its handlers in turn (as below).
  
                         audio.dispose(vars.soundtrack1); vars.soundtrack1 = nil
                         audio.dispose(vars.soundtrack2); vars.soundtrack2 = nil    
                         audio.dispose(vars.sfx1); vars.sfx1 = nil    
                         audio.dispose(vars.sfx2); vars.sfx2 = nil    
                         audio.dispose(vars.sfx2); vars.sfx2 = nil    
                         audio.dispose(vars.sfx2); vars.sfx2 = nil    
                         audio.dispose(vars.sfx2); vars.sfx2 = nil          

     

We have 30 pages of up to 20 audio files each page. It seems to be needless work to have to use audio.dispose and nil each one.

As you can see, we have put all the handlers in a table called vars {}. Can the table be emptied and nil’ed and would that dispose of the audio somehow?

Ideas would be appreciated, thanks.

        

[lua]

for k, v in pairs(tableContainingAllTheAudio) do

audio.dispose(tableContainingAllTheAudio[k])

tableContainingAllTheAudio[k]=nil

end

[/lua]

That should do it :slight_smile:

Brilliant. Thanks very much Caleb, worked a treat.

[lua]

for k, v in pairs(tableContainingAllTheAudio) do

audio.dispose(tableContainingAllTheAudio[k])

tableContainingAllTheAudio[k]=nil

end

[/lua]

That should do it :slight_smile:

Brilliant. Thanks very much Caleb, worked a treat.