initial commit, hope i didnt push any keys :P
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
extends AudioStreamPlayer
|
||||
class_name AudioArrayPlayer
|
||||
|
||||
signal all_finished()
|
||||
|
||||
export var queue := []
|
||||
|
||||
func stop():
|
||||
queue.clear()
|
||||
.stop()
|
||||
|
||||
func _ready():
|
||||
self.connect("finished", self, "_finished")
|
||||
|
||||
func start():
|
||||
if len(queue) > 0:
|
||||
var new = queue[0]
|
||||
if new is float:
|
||||
get_tree().create_timer(new).connect("timeout", self, "_finish_delay")
|
||||
return
|
||||
stream = new
|
||||
stream.loop
|
||||
if !playing:
|
||||
play()
|
||||
else:
|
||||
emit_signal("all_finished")
|
||||
|
||||
func _finish_delay():
|
||||
next()
|
||||
|
||||
func next():
|
||||
queue.pop_front()
|
||||
start()
|
||||
|
||||
func _finished():
|
||||
next()
|
||||
|
||||
|
||||
func play_all(extra:=[]):
|
||||
add_streams(extra)
|
||||
start()
|
||||
|
||||
func add_stream(new:AudioStream):
|
||||
queue.append(new)
|
||||
|
||||
func add_streams(new:Array):
|
||||
queue.append_array(new)
|
||||
Reference in New Issue
Block a user