How to Play an MP3 File in Google Sheets

This tutorial explains how to embed an audio file in Google Sheets and play the MP3 audio when you click the Play button.

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 = `<iframe src="${cell}" width="480" height="180" frameborder="0" scrolling="no"></iframe>`;
  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/<file-id>/preview.

Amit Agarwal

Amit Agarwal

Google Developer Expert, Google Cloud Champion

Amit Agarwal is a Google Developer Expert in Google Workspace and Google Apps Script. He holds an engineering degree in Computer Science (I.I.T.) and is the first professional blogger in India.

Amit has developed several popular Google add-ons including Mail Merge for Gmail and Document Studio. Read more on Lifehacker and YourStory

Awards & Titles

Digital Inspiration has won several awards since it's launch in 2004.

Google Developer Expert

Google Developer Expert

Google awarded us the Google Developer Expert award recogizing our work in Google Workspace.

ProductHunt Golden Kitty

ProductHunt Golden Kitty

Our Gmail tool won the Lifehack of the Year award at ProductHunt Golden Kitty Awards in 2017.

Microsoft MVP Alumni

Microsoft MVP Alumni

Microsoft awarded us the Most Valuable Professional (MVP) title for 5 years in a row.

Google Cloud Champion

Google Cloud Champion

Google awarded us the Champion Innovator title recognizing our technical skill and expertise.

Email Newsletter

Sign up for our email newsletter to stay up to date.

We will never send any spam emails. Promise.