CHECKING STATUS
I AM LISTENING TO
|

Hosting MP3 files on Google Drive + HTML5 Audio Player

5. February 2022
.SHARE

Table of Contents

What Google Drive Sharing offers us!

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.

Apply a simple RegEX

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";

preg_match("/https:\/\/drive.google.com\/file\/d\/([a-zA-Z0-9_]+)\//", $input, $match);

$GoogleDriveFileID = $match[1];

JAVASCRIPT

var input = "https://drive.google.com/file/d/78BygKccgGms9ET2lUM0RPVUI1T0U/view?usp=sharing";

var res = input.match(/https:\/\/drive.google.com\/file\/d\/([a-zA-Z0-9_]+)\//)

var googleDriveFileID = res[1];

Just use it!

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>

Let’s Talk!

Looking for a reliable partner to bring your project to the next level? Whether it’s development, design, security, or ongoing support—I’d love to chat and see how I can help.

Get in touch,
and let’s create something amazing together!

RELATED POSTS

Updated: 03/2026 When I first put together the open-source KPI roundup back in October 2025, the landscape was already impressive. Fast forward to early 2026 and things have moved fast — we’re talking major version releases, AI features landing in free tiers, and a couple of genuinely exciting new tools that deserve a spot on […]

A lot has evolved since I shared my top Docker picks in 2025. I’ve streamlined the whole setup, cut the noise, and focused on what I actually use — locally and externally. Better organised, better documented, and somehow more enjoyable than ever. Could not stick to 10, so its 10++++! My Top Universal Docker Solutions […]

Spam hasn’t gone anywhere. Keep coming back to it, as I hate cleaning up my INBOX and so do my clients! In fact, AI-generated spam has made the problem noticeably worse through 2025 and into 2026 — it’s more convincing, passes basic heuristic checks that would’ve flagged template spam instantly, and arrives in higher volumes. […]

Alexander

I am a full-stack developer. My expertise include:

  • Server, Network and Hosting Environments
  • Data Modeling / Import / Export
  • Business Logic
  • API Layer / Action layer / MVC
  • User Interfaces
  • User Experience
  • Understand what the customer and the business needs


I have a deep passion for programming, design, and server architecture—each of these fuels my creativity, and I wouldn’t feel complete without them.

With a broad range of interests, I’m always exploring new technologies and expanding my knowledge wherever needed. The tech world evolves rapidly, and I love staying ahead by embracing the latest innovations.

Beyond technology, I value peace and surround myself with like-minded individuals.

I firmly believe in the principle: Help others, and help will find its way back to you when you need it.