Open
Description
Godot version
3.3.3 stable
System information
Windows 7 64-bit
Issue description
When using AudioStreamPlayer and setting the stream playback in code, you must use play() to begin playing the file before you seek to a position, or else you'll always play at the beginning. If you set the stream in the AudioStreamPlayer inspector, you may seek() before using play() and it'll work fine.
Steps to reproduce
onready var audiostream = $AudioStreamPlayer
var filelong
export (AudioStreamOGGVorbis) var soundfile
func _ready():
var rng = RandomNumberGenerator.new()
rng.randomize()
audiostream.set_stream(soundfile)
filelong = soundfile.get_length()
audiostream.seek(rng.randf_range(0, filelong))
audiostream.play()
print(audiostream.get_playback_position())
This will print 0 every time, however:
audiostream.play()
audiostream.seek(rng.randf_range(0, filelong))
print(audiostream.get_playback_position())
This will print the playback position at a random time.
Minimal reproduction project
No response