添加按钮以打开侧边栏并播放特定的嵌入式音轨

时间:2017-03-20 21:41:46

标签: audio google-sheets-api

我正在创建一个在侧边栏中有一系列嵌入式音轨的Google表格。目标是让人们收听各种音轨并在电子表格中对访谈进行编码。

如果我可以在电子表格中包含一个按钮,点击它会打开侧边栏并播放特定的音轨,那会很棒吗?

提前致谢!

这是我到目前为止所做的:

CODE:


function onOpen(e) {
   SpreadsheetApp.getUi() 
  .createAddonMenu()
  .addItem('Show sidebar', 'showSidebar')
  .addToUi();
}

function onInstall(e) {
  onOpen(e);
}

function showSidebar() {
  var ui = HtmlService.createTemplateFromFile('Sidebar')
  .evaluate()
  .setSandboxMode(HtmlService.SandboxMode.IFRAME)
  .setTitle(SIDEBAR_TITLE);
SpreadsheetApp.getUi().showSidebar(ui);
}

HTML:
<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    <!-- Use a templated HTML printing scriptlet to import common stylesheet -->
<?!= HtmlService.createHtmlOutputFromFile('Stylesheet').getContent(); ?>

<div class="sidebar branding-below">
    <audio id="player" controls>
      <source src="https://docs.google.com/uc?    export=download&id=0BzdQx2zfyYbTUmNWd3M3MF80bGs" type="audio/mpeg">
      Your browser does not support the audio element.
    </audio>
     <audio id="player" controls>
      <source src="https://docs.google.com/uc?    export=download&id=0BzdQx2zfyYbTVWI2V2JXRGRoMVE" type="audio/mpeg">
      Your browser does not support the audio element.
    </audio>
     <audio id="player" controls>
      <source src="https://docs.google.com/uc?    export=download&id=0BzdQx2zfyYbTdW9YelZfYS1vTlU" type="audio/mpeg">
      Your browser does not support the audio element.
    </audio>
     <audio id="player" controls>
      <source src="https://docs.google.com/uc?export=download&id=0BzdQx2zfyYbTX1RiWE43UVhPN0E" type="audio/mpeg">
      Your browser does not support the audio element.
    </audio>
    <div id="sidebar-status"></div>
</div>

<div class="sidebar bottom">
  <span class="gray branding-text">Docs Add-on Sound Demo</span>
</div>
  </body>
</html>

0 个答案:

没有答案