I have an app that loads some sounds when the app launches then loads sounds as new screens come on to screen. I am trying to remove sounds from memory when the screen is done. On my android phone if I go into data/data/com…/files/coronaResources I see all the sounds I loaded and can not seem to get them removed. I would assume that if I was removing sounds correctly then the sound files should be removed from the directory when in use.
Here is some code pieces, any help would be appreciated, this has been driving me insane.
loading initial sounds (I would like these to stay in memory)
local yeaSounds = {}
yeaSounds[1] = audio.loadSound("congratulations.mp3")
yeaSounds[2] = audio.loadSound("goodjob.mp3")
yeaSounds[3] = audio.loadSound("smart.mp3")
yeaSounds[4] = audio.loadSound("wow.mp3")
yeaSounds[5] = audio.loadSound("yaya.mp3")
local wrongSounds = {}
wrongSounds[1] = audio.loadSound("goodtry.mp3")
wrongSounds[2] = audio.loadSound("oops.mp3")
wrongSounds[3] = audio.loadSound("sorry.mp3")
wrongSounds[4] = audio.loadSound("tryagain.mp3")
So if the user gets the correct item then that specific sound is loaded and played
local i = math.random(5)
audio.play( yeaSounds[i], {onComplete=playWord} )
function playWord()
if soundOn == true then
audioFile = audio.loadSound( content[playOrder[currQuestion]].id..".mp3" )
audio.play( audioFile, { channel=29, onComplete=disposeSound } )
Once the sound is played it goes to disposeSound which I would like to unload the sound from memory
function disposeSound ( event )
print("dispose start fucntion")
audio.stop( 29 )
audio.dispose( 29 )
audioFile = nil
showWord()
print("dispose function")
end
It seems to complete becuase it calls the disposeSound as well as prints out the to print commands but doesnt seem to remove sound from memory.
[import]uid: 73307 topic_id: 20923 reply_id: 320923[/import]