Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Plyr | 23,418 | 277 | 145 | 6 days ago | 153 | April 20, 2022 | 806 | mit | JavaScript | |
A simple HTML5, YouTube and Vimeo player | ||||||||||
Lightgallery | 5,730 | 122 | 26 | a month ago | 107 | September 19, 2022 | 50 | other | TypeScript | |
A customizable, modular, responsive, lightbox gallery plugin. | ||||||||||
Lightgallery.js | 5,223 | 54 | 25 | 8 months ago | 15 | October 29, 2020 | 2 | other | JavaScript | |
Full featured JavaScript image & video gallery. No dependencies | ||||||||||
Youtube | 2,471 | 21 hours ago | 314 | other | JavaScript | |||||
YouTube Extension: Enrich your YouTube experience & content [🧰80 lean Features][📌Longest-standing][Please👨👩👧👧docu. /HowTo's]⚙️⋮{🎞️☕🎛️🎧🔊⏯️🎬🎨📈🧩🧪} Youtube Player Repeat Screenshot | Hide related video youtube distraction Youtube ads expand Description Speed-watching Video Quality codec co2 Player Size Full Tab playback custom Themes | ||||||||||
Chromeplay | 204 | 5 years ago | 17 | gpl-2.0 | JavaScript | |||||
AirPlay from Google Chrome - send YouTube, Vimeo and (almost) any HTML5 video to AppleTV via AirPlay | ||||||||||
Vlite | 158 | 1 | 1 | 3 months ago | 22 | September 09, 2022 | 1 | mit | TypeScript | |
🦋 vLitejs is a fast and lightweight Javascript library for customizing video and audio player in Javascript with a minimalist theme (HTML5, Youtube, Vimeo, Dailymotion) | ||||||||||
Youtube To Html5 Loader | 99 | 8 months ago | 10 | July 21, 2022 | 13 | JavaScript | ||||
Load YouTube videos with the HTLML5 <video> element without needing iframes or the YouTube JS API. | ||||||||||
Advanced Responsive Video Embedder | 34 | 3 days ago | 7 | gpl-3.0 | PHP | |||||
Probably the the best WP plugin for embedding videos. | ||||||||||
Meisterplayer | 14 | 3 years ago | 39 | other | JavaScript | |||||
Pluggable JavaScript web player | ||||||||||
Twine_fullscreen_youtube | 8 | 8 years ago | gpl-3.0 | JavaScript | ||||||
A small macro and stylesheet for Twine to add fullscreen HTML5 video to passages. |
First you need to include the library in your project, this can be achieved via NPM or jsDeliver.
npm i @thelevicole/youtube-to-html5-loader
import YouTubeToHtml5 from '@thelevicole/youtube-to-html5-loader'
<script src="https://cdn.jsdelivr.net/npm/@thelevicole/[email protected]/dist/YouTubeToHtml5.js"></script>
First setup your HTML something like:
<video data-yt2html5="YOUTUBE_URL_OR_ID_GOES_HERE"></video>
And then simply initiate the library with:
new YouTubeToHtml5();
There are a number of options that can be passed to the constructor these are:
| Option | Description | Type | Default |
|--|--|--|--|
| endpoint
| This is the API url thats used for retrieving data. More information to come. | string
| https://yt2html5.com/?id=
|
| selector
| The DOM selector used for finding video elements. | string
| video[data-yt2html5]
|
| attribute
| This is the attribute where your YouTube id/url is stored on the element. | string
| data-yt2html5
|
| formats
| Filter the API results by specific formats. For example [ '1080p', '720p' ]
will only allow 1080p and 720p formats. An asterix will allow all streaming formats. | string|array
| *
|
| autoload
| Whether or not to load all videos on library init. | boolean
| true
|
| withAudio
| Whether or not to only load streams with audio. | boolean
| true
|
| withVideo
| Whether or not to only load streams with video. | boolean
| true
|
This package uses a man-in-the-middle server (yt2html.com) to handle the API requests. This can cause issues as YouTube often blocks the host causing the library to not work. A solution to this is to host your own man-in-the-middle server and change the libraries API endpoint.
Simply modify the libraries global endpoint with the below snippet. Make sure to place before any YouTubeToHtml5()
initiations.
YouTubeToHtml5.defaultOptions.endpoint = 'http://myserver.com/?id=';
The server source can be found here: thelevicole/youtube-to-html5-server
The library has a hook mechanism for filters and actions. If you've worked with WordPress before you'll be familiar with this concept.
Note: You'll need to disable auto loading when using any hooks. First create an instance, then bind your hooks and finally call the
.load()
method.
Modify and return values.
You might want to modify the request URL on each element load. You can do this with the request.url
filter. For example:
const controller = new YouTubeToHtml5({
autoload: false
});
controller.addFilter('request.url', function(url) {
return `${url}&cache_bust=${(new Date()).getTime()}`;
});
controller.load();
Run code every time the action is called.
const controller = new YouTubeToHtml5({
autoload: false
});
controller.addAction('load.before', function(element, data) {
element.classList.add('is-loading');
});
controller.load();
const controller = new YouTubeToHtml5({
autoload: false
});
controller.addAction('load.after', function(element, data) {
element.classList.remove('is-loading');
});
controller.load();
const controller = new YouTubeToHtml5({
autoload: false
});
controller.addAction('load.success', function(element, data) {
element.classList.addClass('is-playable');
});
controller.load();
const controller = new YouTubeToHtml5({
autoload: false
});
controller.addAction('load.failed', function(element, data) {
element.classList.add('is-unplayable');
});
controller.load();
The library now includes a simply jQuery plugin which can be used like so...
$('video[data-yt2html5]').youtubeToHtml5();
The .youtubeToHtml5()
plugin returns the YouTubeToHtml5
class instance so adding hooks etc is just as described above...
const controller = $('video[data-yt2html5]').youtubeToHtml5({
autoload: false
});
controller.addAction('load.failed', function(element, data) {
element.classList.add('is-unplayable');
});
controller.load();
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