How to play google drive mp3 file using html audio tag?

sans picture sans · Sep 4, 2015 · Viewed 15.7k times · Source

My aim is to play the mp3 file from the google drive. I am using the plugin MediaElement js. The reference I got is https://www.portalzine.de/dev/html5/hosting-mp3-files-on-google-drive-html5-audio-player/ This is working in chrome, Mozilla firefox but not in IE-11, safari and opera. I want this to be play in all browsers. Please give me the suggestions....

Answer

ivsuleman picture ivsuleman · Feb 25, 2019

1. URL for the audio file (anyone can view) https://drive.google.com/file/d/1nQklEicsMeGBnuk0vv6zkHtXtyGy10S-/view?usp=sharing

2. Extract the id from URL 1nQklEicsMeGBnuk0vv6zkHtXtyGy10S-

3. URL for playing the audio file https://docs.google.com/uc?export=download&id=1nQklEicsMeGBnuk0vv6zkHtXtyGy10S-

4. URL for downloading the audio file https://drive.google.com/uc?authuser=0&id=1nQklEicsMeGBnuk0vv6zkHtXtyGy10S-&export=download

5. HTML for playing audio:

<audio controls="controls">
  <source src="https://docs.google.com/uc?export=download&id=1nQklEicsMeGBnuk0vv6zkHtXtyGy10S-">
</audio>

6. HTML for downloading audio:

<a href="https://drive.google.com/uc?authuser=0&id=1nQklEicsMeGBnuk0vv6zkHtXtyGyO9S-&export=download"/>Download