openplayerjs-youtube
Version:
OpenPlayer extension to play YouTube videos
61 lines (43 loc) • 2.5 kB
Markdown

# [OpenPlayer.js - YouTube](https://www.openplayerjs.com)
[](https://www.jsdelivr.com/package/npm/openplayerjs-youtube)
Now you can play any YouTube videos using the awesome OpenPlayerJS!
## 🚨 IMPORTANT 🚨
### 🔧 This repository is in maintenance at this point. 🔧
No new features or additions will be added, only bug fixes.
## Installation
1. Set the video/audio as indicated in the [OpenPlayerJS installation](https://github.com/openplayerjs/openplayerjs#installation).
2. Set the `type` of your source as `video/x-youtube`.
3. Load this package library right after [OpenPlayerJS](https://github.com/openplayerjs/openplayerjs).
4. And voilá!
## Configuration
It allows you to override YouTube's configuration by using the `youtube` object in the settings. Check [Supported parameters section](https://developers.google.com/youtube/player_parameters#Parameters) for more details.
## Example
```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>
```
## A word about Privacy
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](https://axbom.com/embed-youtube-videos-without-cookies/).