Replaying a already used audio file (Help Needed)

This feels like such a small problem but I have been searching everywhere and can not seem to fix this.

How do I replay a audio file that has finished? I have tried rewinding it but it never seems to work after it has been used once.

Example of what I mean. You shoot a Enemy1[i] ship and that ship explodes so it plays the explode ship. Now you shoot another Enemy1[i] and replay that same sound effect (Enemy1Die is the name on channel 6) and no sound comes out?

I have tried using the rewind, I have tried just messing around with it and a bunch of different ways, nothing seems to work. I feel like I am missing some very simple piece like “replay” or something but I am out of ideas.

You don’t need to rewind sounds if you are using them over and over.

What’s best is to declare the sound first and then play it on any available channel when required like so.

This will play the sound right away, then continue playing it every 3 seconds as an example.

[lua]

local sound = audio.loadSound(“mysound.wav”)

audio.play(sound)

local function playforever(event)

     audio.play(sound)

end

timer.performWithDelay(3000,playforever,0)

[/lua]

At first what you said made no sense because that is what I have, then I realized I have it written as…

EnemyDie1 = audio.play( EnemyDie1 )

not

audio.play( EnemyDie1 )

and by getting rid of the “EnemyDie1 =” it now works… I don’t understand why putting “EnemyDie1 =” made it not repeat but it did… thank you

You don’t need to rewind sounds if you are using them over and over.

What’s best is to declare the sound first and then play it on any available channel when required like so.

This will play the sound right away, then continue playing it every 3 seconds as an example.

[lua]

local sound = audio.loadSound(“mysound.wav”)

audio.play(sound)

local function playforever(event)

     audio.play(sound)

end

timer.performWithDelay(3000,playforever,0)

[/lua]

At first what you said made no sense because that is what I have, then I realized I have it written as…

EnemyDie1 = audio.play( EnemyDie1 )

not

audio.play( EnemyDie1 )

and by getting rid of the “EnemyDie1 =” it now works… I don’t understand why putting “EnemyDie1 =” made it not repeat but it did… thank you