Embedding Google Drive videos
Google drive is a handy place to store videos. I find myself having more and more videos saved there since Google added call recording to Google Meet, as the resulting recording gets saved to the organiser's drive. Often those videos need to be shared and embedded elsewhere (internal presentations, etc), but finding the embed code for these videos isn't nearly as simple as with Youtube or Vimeo!
Load the video
Open the video in Google drive, then when it has loaded, click the 3 dots in the top right of the screen. On the panel which appears, click "Open in new window".
Embed item
In the new window which has opened, again click the three dots in the top right, and select "Embed item..."
Get the code
A modal pops up, which contains the embed code for this video. This code can be pasted wherever the embed needs to be shared.
All done?
Not quite! Notice in the previous screenshot the yellow box with Only the owner and explicitly shared collaborators have access
. By default, if anyone trying to view the embed doesn't already have access to the underlying video file, the embed won't work.
This may be desired behaviour in some cases (an internal training video limited to users on the same email domain, for example), but what if we want our video to behave a bit more like Youtube, and be visible by anyone?
If we click the three dots at the top right once more, and select "Share", we have the option to make the file globally-visible.
Selecting Anyone with the link
then clicking Done
means that our embed code should now work for anyone who tries to view it!
Well, almost anyone...
These video embeds are not nearly as reliable as YouTube or Vimeo. If you embed a video, with "anyone with the link"-level access, at the time of writing (Jan 23) it will still only work for some of your users. If your user is logged into a gmail account of any type (gmail.com or Google Apps), it'll work fine. If they're not logged into a gmail account, the video won't play, despite the permission settings appearing to be open to all. This can be quite a pain, as there isn't a good error message shown to users to let them know why this has failed.
Hopefully this is something Google will resolve at some point. Until then, YouTube and Vimeo are still the best bet for videos requiring wide distribution. But if you're looking to embed a Drive-based video for a known audience (or one which you know will all be logged into a gmail account of some description..) then the above guide should do the trick!
International PHP Conference
Munich, November 2024
In November 2024, I'll be giving a talk at the International PHP Conference in Munich, Germany. I'll be talking about the page speed quick wins available for backend developers, along with the challenges of policing dangerous drivers, the impact of TV graphics on web design, and the times when it might be better to send your dev team snowboarding for 6 months instead of writing code!
Get your ticket now and I'll see you there!