Protected Video Plugin
YouTube/Vimeo player that prevents easy sharing of the video.
Gutenberg block and Shortcode for embedding YouTube/Vimeo videos, in a way that prevents users easily accessing the underlying video.
This is useful for example when embedding an “unlisted” video as premium course content behind a paywall on your site.
Features include:
- Plyr player used to overlay default player with custom controls
- Player modifications to always prevent clicking the default player
- Encodes video ID in HTML to prevent finding it via “View Source”
- Settings page to e.g. configure the player theme to match your site
View Player Demo
Note: This only provides a basic level of protection. Technical users may still be able to access the underlying video.
This plugin is open source and contributions are welcome on GitHub.
Installation
- Install and activate the plugin
- Optionally configure player theme at Settings > Protected Video
- Search for and use “Protected Video” block in the Block Editor
- Alternatively use the Shortcode e.g.
[protected_video url="https://youtu.be/aqz-KE-bpKQ" service="youtube"]
Screenshots
Searching for Protected Video in the Block Editor.
Protected Video block inserted in the Block Editor.
Protected Video displayed on public facing site.
Configuration of the global plugin settings.
Optional Shortcode embed method also supported.
FAQ
What does this plugin do? Embeds YouTube/Vimeo videos on your pages and takes steps to prevent users obtaining the e.g. YouTube URL of the video by clicking on the player or viewing the page source.
Watch this YouTube video for an introduction to the plugin and its potential use cases.
How secure is this plugin? This plugin only provides a basic level of protection against users accessing the default player or otherwise determining the video URL. Technical users may still be able to figure out this information.
Does this plugin work on mobile? Yes, the custom player works on mobile browsers and the disabling of access to the default player is still in place even in fullscreen mode.
Why not use plain Plyr player? The default Plyr player overlays YouTube/Vimeo players with its own controls, which prevents access to the underlying video copy/share buttons under some scenarios, but this is a side-effect of the way it works rather than a feature. The goal of Protected Video is to make this a feature by accounting for more scenarios e.g. when the player is paused, and providing additional features such as obfuscation of the underlying video ID in the HTML.
If you don’t care about your users sharing the video or actually want them to, a plugin like WP YouTube Lyte is probably more suitable.
How can I style the player with CSS? The main color of the player can be configured at Settings > Protected Video. If you’d like to style the player further, you can provide your own CSS to override the player’s CSS variables:
<style> :root { --plyr-badge-background: #000; --plyr-control-radius: 5px; } </style>
Can the YouTube watermark/controls be hidden? Unfortunately not. This plugin loads the standard YouTube player behind the overlay, which we have no control over. These aspects of the YouTube player cannot be disabled.
Can you add feature X to the player? This plugin embeds the Plyr player in a particular way and adds modifications to prevent access to the underlying video player. This plugin cannot provide additional features to the player itself beyond what is provided by Plyr. If you’d like to see a feature added to the player, please open an issue on Plyr’s GitHub.
Can I load my own videos into the player? Currently this plugin only supports YouTube and Vimeo embeds. You can upload your videos to YouTube or Vimeo and then embed them using this plugin. Support for loading your own video file directly from a server is a potential future feature.
Why is there a Shortcode as well as Gutenberg block? The Shortcode is provided as an alternative embed method that still provides the same level of protection. Some people need the Shortcode for use with 3rd party page builders (Elementor etc.) and others simply prefer using a Shortcode over Gutenberg blocks.
How do I use the Shortcode embed method? This is the format to use if you’d like to use the Shortcode embed method:
[protected_video url="https://youtu.be/aqz-KE-bpKQ" service="youtube"]
A service
of either youtube
or vimeo
must be specified when using the Shortcode embed method.
How can I set the dimensions of the player? The Plyr player is responsive by default and will grow to fill the container it is placed in. If you’d like to restrict these dimensions, place the block or Shortcode within a container that has your desired dimensions. See this support topic for more.
The display of the player is broken/it doesn’t work If the player is not looking or behaving like the demo on your site, this usually indicates another theme or plugin is interfering with Protected Video.
Please try disabling all other plugins one by one and switching to a default theme, to isolate which plugin or theme is causing the issue.
For performance reasons, Protected Video only loads its associated JS and CSS when it detects that a Gutenberg block or Shortcode is present on the page. If you insert a video in a non-standard way this detection may fail.
Changelog