From ce7b2c939dc3dbd6502881780f64e0e6ab7ca8d3 Mon Sep 17 00:00:00 2001 From: Stephen Harrison Date: Mon, 3 Apr 2023 15:06:28 +0100 Subject: [PATCH] Improve audio fade responsiveness --- src/actions.js | 3 ++- src/api.js | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/actions.js b/src/actions.js index 013e63c..45efbfd 100644 --- a/src/actions.js +++ b/src/actions.js @@ -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 }, } diff --git a/src/api.js b/src/api.js index b5e88b9..507f1ac 100644 --- a/src/api.js +++ b/src/api.js @@ -115,6 +115,7 @@ 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 @@ -122,6 +123,7 @@ export default { 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() @@ -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('/')) { @@ -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('/')) { @@ -353,7 +355,7 @@ export default { this.gotOptions.json = undefined this.processResult(response) }, - + /** * INTERNAL: Callback for REST calls to process the return * @@ -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`) }