当前位置:首页 > 未分类 > 正文内容

How to Play an MP3 File in Google Sheets

ceacer3周前 (05-02)未分类8266

You can put the link of any MP3 audio file in Google Sheets but when you click the file link, the audio would not play. You can however add a button in your Google Sheet that, when clicked, will play the MP3 file in a modal window.

Here’s a demo:

MP3 Player in Google Sheets

The audio files are hosted on Google Drive and when the Play button is clicked, the app will open a modal window with the audio player.

Add the Audio Player Button

To get started, create a new Google Sheet, go to the Insert menu and select the Create a New Drawing option. Select Beveled Rectangle from the list of shapes, add some inline text and click Save to insert the button to your active Google Sheet.

Play Audio Button

Add the Player Script

Next, inside the Extension menu of Google Sheets, go to Script Editor and paste the following script.

const openAudioPlayer = () => {
  const cell = SpreadsheetApp.getActiveSheet().getActiveCell().getValue();
  const html = ``;
  const dialog = HtmlService.createHtmlOutput(html).setTitle('Play').setWidth(500).setHeight(200);
  SpreadsheetApp.getUi().showModelessDialog(dialog, 'Play Audio');
};

Switch to the Google Sheet you created, right-click the Play button and assign the openAudioPlayer script to the button.

Audio Player in Google Sheets

Click OK to save your changes. Now play the URL of any MP3 file in any Google Sheet cell, click the Play button and the audio will play in a modal window.

Please ensure that the cell containing the audio file link is active when you click the Play button.

Also, if you are hosting the sound files in your Google Drive, the format of the link should be https://drive.google.com/file/d//preview.

相关文章

How to Send Email Reminders for Google Forms Automatically

How to Send Email Reminders for Google Forms Automatically

You are using Google Forms to collect registrations for an upcoming event and would like to send ema...

The Best Google Add

The availability of third-party add-ons for Google Docs, Sheets and Google Slides have certainly mad...

How to Mail Merge with Outlook and Google Sheets

How to Mail Merge with Outlook and Google Sheets

The Mail merge add-on for Gmail lets you send personalized emails to your contacts in bulk. You can...

Google Maps Formulas for Google Sheets

Google Maps Formulas for Google Sheets

You can bring the power of Google Maps to your Google Sheets using simple formulas with no coding. Y...

Formulas in Google Sheets Disappear When New Rows Are Added

Formulas in Google Sheets Disappear When New Rows Are Added

An order form, created in Google Forms, requires customers to provide their full name, the item quan...