I am doing a Podcast on portalZINE.TV since last year and always host a backup of the MP3 episodes on Google Drive.
The link that you create, when enabling file sharing on Google Drive, can not be used to actually embed it on your website.
The link looks something like that:
https://drive.google.com/file/d/78BygKccgGms9ET2lUM0RPVUI1T0U/view?usp=sharing
To actually use it directly, we need to get the ID. Sure, you could just extract the ID, but often we just want to copy and paste. The sharing link is also your actual reference to the original file, which I store together with the podcast.
We use a simple Regex to extract the ID:
https://drive.google.com/file/d/([a-zA-Z0-9_]+)\/
PHP
$input = "https://drive.google.com/file/d/78BygKccgGms9ET2lUM0RPVUI1T0U/view?usp=sharing"; $GoogleDriveFileID = $match[1];
JAVASCRIPT
var input = "https://drive.google.com/file/d/78BygKccgGms9ET2lUM0RPVUI1T0U/view?usp=sharing"; var googleDriveFileID = res[1];
This ID can than be used to embed the file directly using HTML5 audio controls.
Its important to use the “https://docs.google.com/uc?export=open&id=” url to open the file, as it provides the direct access to the shared file
<audio controls> <source src="https://docs.google.com/uc?export=open&id=<?php echo $GoogleDriveFileID; ?>" type="audio/mp3"> <p>This browser does not support HTML5 audio</p> </audio>
BOOKING SOLUTIONS 202x This is my take on a subset of booking, appointment, PMS or… Read More
THE GOAL Create a system cron for WordPress, that is accessible and can be easily… Read More
2024, what's cooking? Slowly getting into the 2024 spirit. 3 projects coming to a close… Read More
Short look back at 2023 This has been a busy and interesting year. I am… Read More
Elementor Pro provides grid containers as an experimental feature. The options provided are limited, when… Read More
Archaeology Travel is an online travel guide for people who enjoy exploring the world’s pasts.… Read More
View Comments
Hey, can you contact me about this. Im trying to make it work but its not working.
Hi Joe,
just tested this with a MP3 file on my Google Drive. This still works like described above.
Regards
Alex
Thank you a lot!!! it's what i'm looking for! Thanks again for sharing
Thanks, this was brilliant!
this doesn work more duh?
Hi,
just tested and this still works as described. Just did a quick testdrive.
Cheers
Alex
Ok. I believe this doesn`t work anymore. Please can you update us? Sept 2020.
I am sorry for not being specific. I mean this works for desktop applications. However if I try to enter a website from a smartphone this doesn`t work. I may have have been doing something wrong. If you have any thoughts on the matter, please let us be enlightened!
Hey there,
I will take a look and try to make your way to enlightenment as easy as possible :)
Cheers
Alex
Still works perfectly for me on Android & iOS. Only had to switch to https for the audio source.