Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
youtube-player-load_iframe_script_content
Advanced tools
Readme
youtube-player
is an abstraction of YouTube IFrame Player API (YIPA).
The downsides of using YouTube IFrame Player API are:
window
).youtube-player
:
/**
* @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.
});
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);
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/).
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:*';
Using NPM:
npm install youtube-player
npm install
npm run build
cd ./examples
npm install
npm run start
This will start a HTTP server on port 8000.
FAQs
YouTube IFrame Player API abstraction.
The npm package youtube-player-load_iframe_script_content receives a total of 5 weekly downloads. As such, youtube-player-load_iframe_script_content popularity was classified as not popular.
We found that youtube-player-load_iframe_script_content demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.