Skip to content

Commit

Permalink
feat: add video segment block (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimeBather committed Jun 26, 2023
1 parent 4446475 commit 9d3d5d9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
26 changes: 26 additions & 0 deletions client/blockly/blocks/segment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,35 @@ export const SegmentAudioBlock = {
"helpUrl": ""
}


export function segmentAudioBlockGenerator(block){
let audio = javascriptGenerator.valueToCode(block, 'audio', javascriptGenerator.ORDER_ATOMIC);
return [`h('audio',{ url: ${audio} })`,javascriptGenerator.ORDER_NONE]
}

export const SegmentVideoBlock = {
"type": "segment_video",
"message0": "视频 %1",
"args0": [
{
"type": "input_value",
"name": "video",
"check": "String"
}
],
"output": "String",
"imports":{koishi:['h']},
"colour": 230,
"tooltip": "",
"helpUrl": ""
}


export function segmentVideoBlockGenerator(block){
let video = javascriptGenerator.valueToCode(block, 'video', javascriptGenerator.ORDER_ATOMIC);
return [`h('video',{ url: ${video} })`,javascriptGenerator.ORDER_NONE]
}

export const ParseSegmentListBlock = {
"type": "parse_segment_list",
"message0": "解析消息元素列表 %1 对每个元素按顺序执行:",
Expand Down Expand Up @@ -114,6 +138,7 @@ export const SegmentBlocks = [
SegmentAtBlock,
SegmentImageBlock,
SegmentAudioBlock,
SegmentVideoBlock,
ParseSegmentListBlock,
currentSegmentBlock
]
Expand All @@ -122,6 +147,7 @@ export const segmentBlockGenerators = {
'segment_at':segmentAtBlockGenerator,
'segment_image':segmentImageBlockGenerator,
'segment_audio':segmentAudioBlockGenerator,
'segment_video':segmentVideoBlockGenerator,
'parse_segment_list':parseSegmentListBlockGenerator,
'current_segment':currentSegmentBlockGenerator
}
7 changes: 7 additions & 0 deletions client/blockly/toolbox.xml
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,13 @@
</shadow>
</value>
</block>
<block type="segment_video">
<value name="video">
<shadow type="text">
<field name="TEXT">https://example.org/example.mp4</field>
</shadow>
</value>
</block>
<block type="parse_segment_list">
<value name="segments">
<shadow type="session_elements"/>
Expand Down

0 comments on commit 9d3d5d9

Please sign in to comment.