Skip to content

Extension to allow YouTube videos to be played by OpenPlayerJS

License

Notifications You must be signed in to change notification settings

openplayerjs/openplayerjs-youtube

Repository files navigation

openplayer

JSDelivr

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.
  2. Set the type of your source as video/x-youtube.
  3. Load this package library right after 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 for more details.

Example

<!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>

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.

About

Extension to allow YouTube videos to be played by OpenPlayerJS

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •