My audio loop isn't playing

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Scavex

I have created a global script for my background audio and it contains only this code :

extends AudioStreamPlayer

func _ready() -> void:
	stream = load("res://Sounds/Soltitude.wav")
	playing = true
	pass

Now when I launch the game audio plays just fine but then it stops for some reason after some time. I selected the loop option while importing audio but I don’t know where things are going wrong

Do you mean it stops in the middle, or does it stop at the end of the file, as if it had no loop?

Note: you don’t need pass

Zylann | 2020-09-10 12:47

It stops in the end as if it has no loop !

Scavex | 2020-09-10 12:57

Oh I fixed it ! I feel so embarrassed. I forgot to reimport the audio track while checking the loop option.

Scavex | 2020-09-10 15:30

Hey! it would be nice if you add the answer you found as an answer, so the question does not remain unanswered

p7f | 2020-09-10 17:05

:bust_in_silhouette: Reply From: Scavex

The reason I was unable to play my audio on loop was because I forgot to reimport the audio file after selecting the loop option. This made the loop end as well as the beginning 0. Simply reimporting the file fixed the issue.

Yeah, after your first comment I was about to tell you that :wink:

Zylann | 2020-09-10 17:43