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

vidzone-sdk

v1.0.3

Published

Vidzone SDK

Downloads

255

Readme

Vidzone HTML5 SDK

Initialization

  1. Install library
npm install vidzone-sdk
  1. Create and init instance of VidzoneSDK:
import VidzoneSDK from 'vidzone-sdk';

const vidzoneSDK = new VidzoneSDK()

vidzoneSDK.init().then(function () {
    //now we are ready to generate nonce 
})
  1. After init has been done and before start loading stream URL - request for nonce:
vidzoneSDK.generateNonce({
    adWillAutoPlay: true,
    adWillPlayMuted: false,
    playerType: "player name",
    playerVersion: "version",
    ppid: "your platform name",
    sessionId: "some UUID",
    url: "https://some.com/some/page",
    videoHeight: 1080,
    videoWidth: 1920,
}).then(function (manager) {
    //start playback and pass nonce
    console.log("nonce generated: ", manager.getNonce())
    startPlayback(manager)
}).catch(function (err) {
    //log error and try to fix
})

Parameters Description

| Name | Type | Description | |-----------------|--------|------------------------------------------------------------------------------------------------------------------------------------------------------------| | adWillAutoPlay | bool | Set to true if the ad will be auto-played without waiting for user interaction. Set to false if the ad will wait for user interaction before being played. | | adWillPlayMuted | bool | Set to true if the ad will be played while muted. Set to false if the ad will play unmuted. | | playerType | string | Your player name. | | playerVersion | string | Your player version. | | ppid | string | Your platform name + geo. | | sessionId | string | The session ID is a temporary random ID. It is used exclusively for frequency capping on connected TVs (smart TVs, game consoles, and set-top-boxes). | | pageUrl | string | The URL to which the ads will be targeted. By default, this is the same as the page that will display the ads, but it may be manually set. | | videoHeight | number | The height of the ad video element. | | videoWidth | number | The width of the ad video element. |

Working with VidzoneNonceManager

After the nonce has been generated, the VidzoneNonceManager object is used to manage playback state.

function startPlayback(manager) {
    let streamURLWithNonce = streamURL + "?vidsdk=" + manager.getExtraParams(); // or append the parameter with ? if there are no other query params in the URL
    console.log("Play stream", streamURLWithNonce);
    playStream(streamURLWithNonce);
    manager.onPlaybackStart();  // Notify the manager that playback has started
}

function onPlaybackEnd(manager) {
    manager.onPlaybackEnd();  // Notify the manager that playback has ended
}

Methods of VidzoneNonceManager

Returns the generated nonce.

let nonce = manager.getNonce();

Notifies the system that the video playback has started.

manager.onPlaybackStart();

Notifies the system that the video playback has ended.

manager.onPlaybackEnd();

Returns the additional parameters to pass in the stream URL.

manager.getExtraParams();

Full Example

import VidzoneSDK from 'vidzone-sdk';

(async function () {
    let v = new VidzoneSDK(true);
    
    try {
        await v.init();
        const manager = await v.generateNonce({
            playerType: "test",
            playerVersion: "v0.1",
            ppid: "some ppid",
            sessionId: "some uuid",
            url: window.location.href || "https://some.com/some/page",
            videoHeight: 1080,
            videoWidth: 1920
        });
        console.log("Nonce generated:", manager.getExtraParams());
        
        // Start playback
        startPlayback(manager);
        
        // End playback when done
        onPlaybackEnd(manager);
    } catch (err) {
        console.error("Error:", err);
    }
})();

function startPlayback(manager) {
    let streamURLWithNonce = "https://stream.url" + "?vidsdk=" + manager.getExtraParams();
    console.log("Play stream", streamURLWithNonce);
    // playStream(streamURLWithNonce);
    manager.onPlaybackStart();
}

function onPlaybackEnd(manager) {
    manager.onPlaybackEnd();
}