Skip to content

Commit

Permalink
Add a play mode to groups that only play the first item
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Boberg <[email protected]>
  • Loading branch information
axelboberg committed Apr 26, 2024
1 parent c85d78d commit ef42196
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions plugins/types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const types = require('./lib/types')
const utils = require('./lib/utils')

const GROUP_PLAY_MODES = {
all: 0
all: 0,
first: 1
}

const PLAY_HANDLERS = {
Expand All @@ -23,10 +24,17 @@ const PLAY_HANDLERS = {
on the group's play mode
*/
'bridge.types.group': item => {
if (!item?.data?.playMode || item?.data?.playMode === GROUP_PLAY_MODES.all) {
for (const child of (item?.children || [])) {
bridge.items.playItem(child)
}
switch (parseInt(item?.data?.playMode)) {
case GROUP_PLAY_MODES.first:
if (item?.children?.[0]) {
bridge.items.playItem(item?.children?.[0])
}
break
case GROUP_PLAY_MODES.all:
default:
for (const child of (item?.children || [])) {
bridge.items.playItem(child)
}
}
},

Expand Down
2 changes: 1 addition & 1 deletion plugins/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"name": "Play mode",
"type": "enum",
"default": 0,
"enum": ["Trigger all children at once"],
"enum": ["Trigger all children at once", "Trigger the first child"],
"ui.group": "Timing"
}
}
Expand Down

0 comments on commit ef42196

Please sign in to comment.