Jump to content

How to Play an MP3 File in Google Sheets


Recommended Posts

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.

View the full article

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. to insert a cookie message