Skip to content

Commit def3586

Browse files
authored
Merge pull request #161 from endlessm/T35582-stop-audio
category_factory: Add pause, stop and continue audio feature
2 parents 90fad21 + fc8f192 commit def3586

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

addons/block_code/ui/picker/categories/category_factory.gd

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,40 @@ static func get_general_blocks() -> Array[Block]:
502502
b.tooltip_text = "Play the audio stream with volume and pitch"
503503
b.category = "Sounds"
504504
block_list.append(b)
505+
506+
b = BLOCKS["statement_block"].instantiate()
507+
b.block_name = "pause_continue_sound"
508+
b.block_type = Types.BlockType.EXECUTE
509+
b.block_format = "{pause: OPTION} the sound {name: STRING}"
510+
b.statement = (
511+
"""
512+
var __sound_node = get_node({name})
513+
if "{pause}" == "pause":
514+
__sound_node.stream_paused = true
515+
else:
516+
__sound_node.stream_paused = false
517+
"""
518+
. dedent()
519+
)
520+
b.defaults = {"pause": OptionData.new(["Pause", "Continue"])}
521+
b.tooltip_text = "Pause/Continue the audio stream"
522+
b.category = "Sounds"
523+
block_list.append(b)
524+
525+
b = BLOCKS["statement_block"].instantiate()
526+
b.block_name = "stop_sound"
527+
b.block_type = Types.BlockType.EXECUTE
528+
b.block_format = "Stop the sound {name: STRING}"
529+
b.statement = (
530+
"""
531+
var __sound_node = get_node({name})
532+
__sound_node.stop()
533+
"""
534+
. dedent()
535+
)
536+
b.tooltip_text = "Stop the audio stream"
537+
b.category = "Sounds"
538+
block_list.append(b)
505539
#endregion
506540
#region Graphics
507541

0 commit comments

Comments
 (0)