Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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....

like image 916
sans Avatar asked Sep 04 '15 07:09

sans


1 Answers

In another thread on another page someone wrote the only solution that has worked for me:

If you share an MP3 by link, you obtain a link like this

https://drive.google.com/file/d/XXXXXXXXXXXXXXXXXX/view?usp=sharing where XXXXXXXXXXXXXXXXXX is the ID of your MP3 file. Then you can obtain a direct link to this audio by

http://docs.google.com/uc?export=open&id=XXXXXXXXXXXXXXXXXX In particular you can use

<audio controls>
   <source src="http://docs.google.com/uc?export=open&id=XXXXXXXXXXXXXXXXXX" type="audio/mp3">
   <p>Your browser does not support HTML5 audio :(</p>
</audio> 

The first link is the one you normally get, the other link is what you want to use with

Try to think of this as HTML code:

<audio controls>    
    <source src="http://docs.google.com/uc?export=open&id=XXXXXXXXXXXXXXXXXX" type="audio/mp3">    
</audio>

Make sure you convert that link right and it will work!

like image 129
Martin Avatar answered Sep 21 '22 18:09

Martin