Skip to content

Commit

Permalink
Improve audio fade responsiveness
Browse files Browse the repository at this point in the history
  • Loading branch information
sphlabs committed Apr 3, 2023
1 parent 004c8ef commit ce7b2c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,11 @@ export default {
newVol = parseFloat(vol) / 100
break
}
console.log(`Volume: ${newVol}`)
const payload = { volume: newVol }
this.sendPutRequest(`documents/${layer.document}/layers/${layer.id}`, payload)
// layer.volume = newVol
const parentDoc = this.documents.find((element) => element.id === layer.document)
parentDoc.layers[layer.index].volume = newVol
},
}

Expand Down
21 changes: 12 additions & 9 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,15 @@ export default {
activeVariant: message.data.relationships['active-variant'].data.id,
liveState: message.data.attributes['live-state'],
volume: message.data.attributes['volume'],
index: message.data.attributes.index
}
} else {
parentDocument.layers[layerIndex].id = message.id
parentDocument.layers[layerIndex].label = message.data.attributes.name
parentDocument.layers[layerIndex].activeVariant = message.data.relationships['active-variant'].data.id
parentDocument.layers[layerIndex].liveState = message.data.attributes['live-state']
parentDocument.layers[layerIndex].volume = message.data.attributes['volume']
parentDocument.layers[layerIndex].index = message.data.attributes.index
}
this.log('debug', `Layer: ${message.data.attributes.name} is ${message.data.attributes['live-state']}`)
this.updateLayerVariables()
Expand Down Expand Up @@ -300,9 +302,9 @@ export default {
},

/**
* Send a REST GET request to the player and handle errorcodes
* @param {} cmd
*/
* Send a REST GET request to the player and handle errorcodes
* @param {} cmd
*/
sendGetRequest: async function (cmd) {
// Trim off any leading / characters
while (cmd.startsWith('/')) {
Expand All @@ -324,12 +326,12 @@ export default {
}
this.processResult(response)
},

/**
* Send a REST PUT request to the player and handle errorcodes
* @param {} cmd
* @param {} payload
*/
* Send a REST PUT request to the player and handle errorcodes
* @param {} cmd
* @param {} payload
*/
sendPutRequest: async function (cmd, payload) {
// Trim off any leading / characters
while (cmd.startsWith('/')) {
Expand All @@ -353,7 +355,7 @@ export default {
this.gotOptions.json = undefined
this.processResult(response)
},

/**
* INTERNAL: Callback for REST calls to process the return
*
Expand Down Expand Up @@ -434,6 +436,7 @@ export default {
liveVariant: '',
liveState: data[layer].attributes['live-state'],
volume: data[layer].attributes['volume'],
index: data[layer].attributes.index
}
this.sendGetRequest(`documents/${parentDocId}/layers/${data[layer].id}/variants`)
}
Expand Down

0 comments on commit ce7b2c9

Please sign in to comment.