Shadowphile There you go:
extends AudioStreamPlayer
var time := 0.0
var pos := 0.0
var slice_max := 0.1
var slice_min := 0.05
var scrub_sensitivity := 0.002
func _input(e):
if e is InputEventMouseMotion and e.button_mask == MOUSE_BUTTON_MASK_LEFT:
scrub(e.relative.x * scrub_sensitivity)
func scrub(relative: float):
pos = clamp(pos + relative, 0, stream.get_length())
print("%d%%"%(100.0 * pos / stream.get_length()))
if time < slice_min or is_equal_approx(pos, 0.0) or is_equal_approx(pos, stream.get_length()):
return
play(pos)
time = 0
func _process(dt):
time += dt
if time > slice_max:
stop()
Drag left-right to scrub. You can map whatever gui action you want to relative argument to scrub()