1

In a self-developed add-on for Google Sheets, the functionality has been added that a sound file will be played from a JavaScript audio player in the side bar, depending on the selection in the table. For the code itself see here.

When users have installed the add-on from the Marktetplace, the add-on works fine only for one user at a time: When the selected row is changed, the corresponding sound file is played automatically (autostart) through the player on the right-hand side.

However, when several users are using this add-on, the audio players in the respective browsers seem to interfere with each other, such that the audio file is interrupted and will start again until is interrupted again, thus, ending up with a loop of interrupting audio files. The problem thus seems to be that running the add-on by more than one user is interrupting and restarting the script permanently.

I do have absolutely no idea where to start investigating this error. What I found out is that, in the multi-user mode, the PHP script to deliver the sound file is started over and over again.

When in single-user mode, this script is only called once.

A reproducible example is accessible here; Add-ons > 'play audio' (Google account necessary). To reproduce the error, the sheet has to be opened two times (e.g. in two browsers).

Peter
  • 77
  • 9
  • How are you calling the audio script file? @Peter – ale13 Nov 11 '20 at 13:00
  • The function `show_record()` constructs an HTML audio tag with the URL to the sound file set as src. See [here](https://stackoverflow.com/questions/58621104/google-spreadsheet-update-value-in-sidebar-when-next-row-is-selected-in-table). – Peter Nov 11 '20 at 13:12
  • Please add a [mcve] – Rubén Nov 11 '20 at 16:30

1 Answers1

2

Looking at the code on the accepted answer to Update value in a spreadsheet sidebar when next row is selected in table the problem is caused due to the use of the Script Properties store because any user that open the sidebar is overwriting the script properties.

The solution is to use the User Properties store. In other words,

instead of

PropertiesService.getScriptProperties()

use

PropertiesService.getUserProperties();

Resources

Rubén
  • 34,714
  • 9
  • 70
  • 166
  • This works perfectly! However, it takes always 1.5 to 2 seconds for the sidebar to reload the next audio when a new row is selected in the table. Is there a possibility to reduce this time? – Peter Nov 12 '20 at 07:57
  • Yes, there's a possibility. I suggest you to post a new question. – Rubén Nov 12 '20 at 12:56