All Projects β†’ gajus β†’ Youtube Player

gajus / Youtube Player

Licence: other
YouTube iframe API abstraction.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Youtube Player

Youtubekit
YoutubeKit is a video player that fully supports Youtube IFrame API and YoutubeDataAPI for easily create a Youtube app
Stars: ✭ 484 (+77.29%)
Mutual labels:  video-player, youtube
Vue Video Player
🎞 @videojs component for @vuejs
Stars: ✭ 4,026 (+1374.73%)
Mutual labels:  video-player, youtube
Piptool
Add the Picture-in-Picture Functionality to YouTube, Netflix, Plex and other video broadcasting services in macOS Sierra
Stars: ✭ 337 (+23.44%)
Mutual labels:  video-player, youtube
Web
Angular6 music player to search and play YouTube, SoundCloud and Mixcloud tracks
Stars: ✭ 156 (-42.86%)
Mutual labels:  video-player, youtube
Youtube Terminal
πŸ“Ί Stream YouTube videos as ascii art in the terminal!
Stars: ✭ 84 (-69.23%)
Mutual labels:  video-player, youtube
Unity Videoplayer Helper
Simple helper for the Video Player in Unity
Stars: ✭ 49 (-82.05%)
Mutual labels:  video-player, youtube
Youtube player flutter
Flutter plugin for playing or streaming YouTube videos inline using the official iFrame Player API. Supports both Android and iOS platforms.
Stars: ✭ 366 (+34.07%)
Mutual labels:  video-player, youtube
Floating Player
Floating Player is a Google Chrome extension to watch videos while you browse the internet
Stars: ✭ 77 (-71.79%)
Mutual labels:  video-player, youtube
Ngx Youtube Player
YouTube player app built with Angular 7
Stars: ✭ 92 (-66.3%)
Mutual labels:  video-player, youtube
BeatSaberCinema
A Beat Saber plugin that allows you to sync up videos to play in the background of your maps.
Stars: ✭ 35 (-87.18%)
Mutual labels:  youtube, video-player
playlist-quarantine-edition
Playlist Quarantine Edition
Stars: ✭ 20 (-92.67%)
Mutual labels:  youtube
framework
A creative coding library.
Stars: ✭ 35 (-87.18%)
Mutual labels:  video-player
Vue Youtube
A simple component for a powerful API. vue-youtube provides a simple layer for you to use your imagination while over the YouTube IFrame Player API.
Stars: ✭ 261 (-4.4%)
Mutual labels:  youtube
Sjfullscreenpopgesture
Fullscreen pop gesture. OC&Swift. It is very suitable for the application of the video player. Support `cocoapods`. εͺιœ€`pod`即可θ‡ͺεΈ¦ε…¨ε±θΏ”ε›žζ‰‹εŠΏ. ζ”―ζŒpod. ζ”―ζŒOC&Swift.
Stars: ✭ 266 (-2.56%)
Mutual labels:  video-player
YourAutoLiker
Browser extension that automatically likes or dislikes Youtube videos from selected channels.
Stars: ✭ 24 (-91.21%)
Mutual labels:  youtube
Myflix
Myflix, a Netflix clone!
Stars: ✭ 260 (-4.76%)
Mutual labels:  video-player
dislike-truck
Youtube Mass Dislike Script
Stars: ✭ 40 (-85.35%)
Mutual labels:  youtube
react-native-vimeo-iframe
No description or website provided.
Stars: ✭ 17 (-93.77%)
Mutual labels:  video-player
youtube-ios-player-helper-swift
A full swift implementation of https://github.com/youtube/youtube-ios-player-helper. Helper library for iOS developers looking to add YouTube video playback in their applications via the iframe player in a UIWebView
Stars: ✭ 55 (-79.85%)
Mutual labels:  youtube
Embera
A Oembed consumer library, that gives you information about urls. It helps you replace urls to youtube or vimeo for example, with their html embed code. It has advanced features like offline support, responsive embeds and caching support.
Stars: ✭ 268 (-1.83%)
Mutual labels:  youtube

YouTube Player

Travis build status NPM version Canonical Code Style Twitter Follow

youtube-player is an abstraction of YouTube IFrame Player API (YIPA).

The downsides of using YouTube IFrame Player API are:

  • Requires to define callbacks in the global scope (window).
  • Requires to track the state of a player (e.g. you must ensure that video player is "ready" before you can use the API).

youtube-player:

  • Registers listeners required to establish when YIPA has been loaded.
  • Does not overwrite global YIPA callback functions.
  • Queues player API calls until when video player is "ready".

Usage

/**
 * @typedef options
 * @see https://developers.google.com/youtube/iframe_api_reference#Loading_a_Video_Player
 * @param {Number} width
 * @param {Number} height
 * @param {String} videoId
 * @param {Object} playerVars
 * @param {Object} events
 */

/**
 * @typedef YT.Player
 * @see https://developers.google.com/youtube/iframe_api_reference
 * */

/**
 * A factory function used to produce an instance of YT.Player and queue function calls and proxy events of the resulting object.
 *
 * @param {YT.Player|HTMLElement|String} elementId Either An existing YT.Player instance,
 * the DOM element or the id of the HTML element where the API will insert an <iframe>.
 * @param {YouTubePlayer~options} options See `options` (Ignored when using an existing YT.Player instance).
 * @param {boolean} strictState A flag designating whether or not to wait for
 * an acceptable state when calling supported functions. Default: `false`.
 * See `FunctionStateMap.js` for supported functions and acceptable states.
 * @returns {Object}
 */
import YouTubePlayer from 'youtube-player';

youtube-player is a factory function.

The resulting object exposes all functions of an instance of YT.Player. The difference is that the function body is wrapped in a promise. This promise is resolved only when the player has finished loading and is ready to begin receiving API calls (onReady). Therefore, all function calls are queued and replayed only when player is ready.

This encapsulation does not affect the API other than making every function return a promise.

let player;

player = YouTubePlayer('video-player');

// 'loadVideoById' is queued until the player is ready to receive API calls.
player.loadVideoById('M7lc1UVf-VE');

// 'playVideo' is queue until the player is ready to received API calls and after 'loadVideoById' has been called.
player.playVideo();

// 'stopVideo' is queued after 'playVideo'.
player
    .stopVideo()
    .then(() => {
        // Every function returns a promise that is resolved after the target function has been executed.
    });

Events

player.on event emitter is used to listen to all YouTube IFrame Player API events, e.g.

player.on('stateChange', (event) => {
    // event.data
});

player.off removes a previously added event listener, e.g.

var listener = player.on(/* ... */);

player.off(listener);

Polyfills

Note that the built version does not inline polyfills.

You need to polyfill the environment locally (e.g. using a service such as https://polyfill.io/v2/docs/).

Examples

Debugging

youtube-player is using debug module to expose debugging information.

The debug namespace is "youtube-player".

To display youtube-player logs configure localStorage.debug, e.g.

localStorage.debug = 'youtube-player:*';

Download

Using NPM:

npm install youtube-player

Running the Examples

npm install
npm run build
cd ./examples
npm install
npm run start

This will start a HTTP server on port 8000.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].