Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@thelevicole/youtube-to-html5-loader

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thelevicole/youtube-to-html5-loader

A javascript library to load YoutTube videos as HTML5 emebed elements.

  • 3.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
443
increased by1.61%
Maintainers
1
Weekly downloads
 
Created
Source

Load YoutTube videos as HTML5 emebed element

Latest Stable Version Total Downloads

Basic usage example

Replacing YOUTUBE_URL_OR_ID_GOES_HERE with your video URL or ID.

<video data-yt2html5="YOUTUBE_URL_OR_ID_GOES_HERE"></video>
<script src="YouTubeToHtml5.js"></script>
<script>new YouTubeToHtml5();</script>

NPM

npm i @thelevicole/youtube-to-html5-loader
const YouTubeToHtml5 = require('@thelevicole/youtube-to-html5-loader');
new YouTubeToHtml5();

jsDelivr CDN

<script src="https://cdn.jsdelivr.net/npm/@thelevicole/youtube-to-html5-loader@3.0.1/dist/YouTubeToHtml5.min.js"></script>

Options example

<video class="youtube-video" data-yt="https://youtube.com/watch?v=ScMzIvxBSi4"></video>
    
<script src="YouTubeToHtml5.js"></script>
<script>
  new YouTubeToHtml5({   
    selector: '.youtube-video',
    attribute: 'data-yt'
  });
</script>

Internal API example

<video data-yt2html5="YOUTUBE_URL_OR_ID_GOES_HERE"></video>
    
<script src="YouTubeToHtml5.js"></script>
<script>   
  var player = new YouTubeToHtml5({
    autoload: false // Disable loading videos on init, `.load()` method is required.
  });

  // Add loading class to video element
  player.addAction('api.before', function(element) {   
    element.classList.add('is-loading');
  });

  // Remove loading class after API HTTP request completes.
  player.addAction('api.after', function(element) {
    element.classList.remove('is-loading');
  });

  // Now we can load videos.
  player.load();
</script>

Accepted URL patterns

Below is a list of varying YouTube url patterns, which include http/s and www/non-www.

youtube.com/watch?v=ScMzIvxBSi4
youtube.com/watch?vi=ScMzIvxBSi4
youtube.com/v/ScMzIvxBSi4
youtube.com/vi/ScMzIvxBSi4
youtube.com/?v=ScMzIvxBSi4
youtube.com/?vi=ScMzIvxBSi4
youtu.be/ScMzIvxBSi4
youtube.com/embed/ScMzIvxBSi4
youtube.com/v/ScMzIvxBSi4
youtube.com/watch?v=ScMzIvxBSi4&wtv=wtv
youtube.com/watch?dev=inprogress&v=ScMzIvxBSi4&feature=related
m.youtube.com/watch?v=ScMzIvxBSi4
youtube-nocookie.com/embed/ScMzIvxBSi4

Keywords

FAQs

Package last updated on 09 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc