npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

adsplayer.js

v1.8.0

Published

Plugin for hasplayer.js used to handle ad-insertion in MAST/VAST format

Downloads

16

Readme

adsplayer.js Build Status

adsplayer.js is a javascript client/module that handles ad-insertion when playing streams with HTML5 based players, such as players using MSE/EME extensions.

adsplayer.js is compatible with MAST file format for describing the list of ad-insertion triggers, and with VAST format for ads playing description. When opening a new stream with hasplayer.js, the adsplayer.js plugin handles ad-insertion in the case a MAST file URL is provided.

adsplayer.js API enables using this module as a plugin/module for hasplayer.js.

The adsplayer.js plugin takes charge of:

  • MAST and VAST files downloading
  • detecting ad-insertion triggers
  • pausing and then resuming the main player video when playing ad(s)
  • opening and playing ad media files, by the help of <video> and <img> HTML components, created by the plugin and appended in the DOM container provided to the plugin

The web application that uses adsplayer.js in cunjunction with a HTML5 player has to take charge of:

  • hiding/showing adsplayer.js components according to the events raised by the plugin
  • opening the web page when a click on the playing ad has been detected by the plugin
  • pausing/resuming the plugin (for example when application visibility changes)

Build / Run

# npm run build

The resulting built file adsplayer.js has to be included along with hasplayer.js.

Releases

The project releases are available at this address:

http://orange-opensource.github.io/adsplayer.js

Getting Started (when using with hasplayer.js)

When creating the hasplayer.js's MediaPlayer instance, create an AdsPlayer instance and add it to the MediaPlayer. The DOM element in which <video> and <img> HTML components will be appended for playing ad(s) has to be provided in the constuctor.

var mediaPlayer = new MediaPlayer();
var adsPlayer = new adsplayer.AdsPlayer(document.getElementById('adsplayer-container'));
mediaPlayer.addPlugin(adsPlayer);

When opening a stream with the MediaPlayer, the MAST file URL has to be provided in the 'adsUrl' stream parameter.

var stream = {
    url: "http://playready.directtaps.net/smoothstreaming/SSWSS720H264/SuperSpeedway_720.ism/Manifest",
    adsUrl: "<mast-file-url>"
};
mediaPlayer.load(stream);

In order to interact with AdsPlayer, the application has to register to some events raised by the AdsPlayer:

adsPlayer.addEventListener("start", function (e) {
    // Ad(s) playback is starting => the application shall show ad(s) player container and hide main video
});
adsPlayer.addEventListener("end", function (e) {
    // Ad(s) playback has ended => the application shall hide ad(s) player container and show main video
});
adsPlayer.addEventListener("addElement", function (e) {
    // A DOM element for playing an ad has been created and will be appended in the ads player container. The element can be either a &lt;video&gt; or an &lt;img&gt; element
});
adsPlayer.addEventListener("removeElement", function (e) {
    // the DOM element for playing an ad is being removed from the ads player container and deleted
});
adsPlayer.addEventListener("play", function (e) {
    // An ad's media playback is starting => the application should update play/pause button
});
adsPlayer.addEventListener("pause", function (e) {
    // An ad's media playback is paused => the application should update play/pause button
});
adsPlayer.addEventListener("click", function (e) {
    // A click has beed detected on the media component => the application shall open the corresponding web page, which URL is contained in parameter e.data.uri
});

AdsPlayer propose some more specific API methods in order to interact with the ad(s) playing:

adsPlayer.pause(); // Pause the playback of the current ad media
adsPlayer.play();  // Play/resume the playback of the current ad media

License

All code in this repository is covered by the BSD-3 license. See LICENSE file for copyright details.

Documentation

This API documentation describing AdsPlayer public methods and events can be generated using following gulp command:

# npm run doc