Hi there! I want to play a sound effect ONCE. To do so, I imported a .wav file into Godot. In the import panel, 'Loop' is NOT checked. Then I assigned the wav to an AudioStreamPlayer3D.

When I call $MySound.play() once in a script, the sound keeps on repeating endlessly.

How can I make sure the sound is only played once? Thanks! :)

This discussion was caught in the moderation queue since you have not confirmed your account yet.

Upon creating your account you should have received an account verification email. The confirmation email may have been incorrectly flagged as spam, so please also check your spam filter. Without confirming your account, future posts may also be caught in the moderation queue. You can resend a confirmation email when you log into your account if you cannot find the first verification email.

(Note: You do not need to repost, the discussion has been moved out and is visible now)

If you need any help, please let us know! You can find ways to contact forum staff on the Contact page. Thanks! :smile:

I saw a tip that might help:

Select the sound file in the File System dock, verify that Loop is unchecked in the Import panel and click Reimport.

@DaveTheCoder said: I saw a tip that might help:

Select the sound file in the File System dock, verify that Loop is unchecked in the Import panel and click Reimport.

yeah, .ogg files are imported with loop by default, I went crazy a day for this

@DaveTheCoder said: I saw a tip that might help:

Select the sound file in the File System dock, verify that Loop is unchecked in the Import panel and click Reimport.

Yeah, Loop is unchecked. I also hit the Reimport button more than once ;-) Sadly this does not change a thing. The sound is still looping...

Your code might just be the one on loop/reevaluated such that it effectively loops.

Interesting, I set stream paused to true and then false again and it's not playing anymore. But even with the line commented out it previously played without stream paused set to true.

edit: So the actual resource seems to still have Looping set to Forward:

However even with it set to disabled via inspector, during runtime it is still somehow set back to "Forward" state according to remote inspection. I think it's a bug.

2 months later

I am having the same issue now, have any fixes been found?

22 days later

I've been having the same issue. I tried using ogg, mp3 nothing. Looping is off. Im beginning to think that this is an actual bug.

I encountered this recently with an AudioStream but my confusion was that Wav files are not looped by default by MP3s are (strange decision). I just click the import tab and deselected loop and reimported.

@mralienboi Can you upload a minimal example of the problem? I can take a look, it is possible there is a bug but maybe it is something wrong in your setup.

I encountered this recently with an AudioStream but my confusion was that Wav files are not looped by default by MP3s are (strange decision). I just click the import tab and deselected loop and reimported.

Sound formats designed to be used for background music and ambient sounds (Ogg Vorbis and MP3) are looped by default, but formats designed for sound effects (WAV) aren't.

This behavior could be changed by default for 4.0, but it will likely break user expectations for anyone realizing that their music won't loop anymore…

Okay. That makes sense. I did look at any docs or anything, I just pasted audio into the project and it tripped me up for a few minutes (I looked online and realized shortly after). It's not a huge deal, since now I know how it works.

2 years later