Now you can play any YouTube videos using the awesome OpenPlayerJS!
No new features or additions will be added, only bug fixes.
- Set the video/audio as indicated in the OpenPlayerJS installation.
- Set the
type
of your source asvideo/x-youtube
. - Load this package library right after OpenPlayerJS.
- And voilá!
It allows you to override YouTube's configuration by using the youtube
object in the settings. Check Supported parameters section for more details.
<!DOCTYPE html>
<html lang="en">
<body>
<video class="op-player__media" id="video" controls playsinline>
<source
src="https://www.youtube.com/watch?v=xcJtL7QggTI"
type="video/x-youtube"
/>
</video>
<script src="https://cdn.jsdelivr.net/npm/openplayerjs@latest/dist/openplayer.min.js"></script>
<script src="/path/to/openplayerjs-youtube.min.js"></script>
<script>
var player = new OpenPlayer("video", {
youtube: {
// config
},
});
player.init();
</script>
</body>
</html>
This YouTube plug-in leverages the Google's YouTube Iframe API, which in turn will allow you to set a regular YouTube URL. However, this URL sets a tracking cookie by default (for marketing purposes).
This alone represents a compliance issue for the European General Data Protection Regulation (GDPR), and potentially for browsers with more strict privacy policies.
This plug-in has an option to disable the cookie in the settings, which in that case is recommended to use in this case: nocookie
; however, this is only one of the multiple steps to achieve an experience that is according to what Privacy Policy expects.
To learn more about how to get a better experience with YouTube and GDPR, check this source.