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

@meisterplayer/plugin-shaka

v5.3.0

Published

Meister plugin wrapping the Shaka player.

Downloads

3

Readme

Shaka plugin for meister

===========

This plugin allows basic media types to be played. They are directly put in the video element.

Installation


You can install this plugin through npm:

npm install @meisterplayer/plugin-shaka

and importing it

import Meister from 'meisterplayer';
import BaseMedia from '@meisterplayer/plugin-shaka'

or using a script tag:

<script src="Meister.js"></script>
<script src="Shaka.js"></script>

Getting started

Load the plugin by adding a Shaka configuration object to the Meister initialisation options. If you don't need to customize anything an empty object is enough.

Example:

var meisterPlayer = new Meister('#player', {
    Shaka: {}
});

meisterPlayer.setItem({
    src: 'https://example.com/secure/stream/manifest.mpd',
    type: 'mpd',
});

meisterPlayer.load();

Configuration

Options are required unless marked as [optional].

  • [optional] dvrThreshold :: Number
    Content with a window longer than this threshold is considered as having a DVR window. This is measured in seconds. Defaults to 300 (5 minutes).
  • [optional] maxErrorCounts :: Object
    This object allows customization of the maximum amount of nonfatal errors before throwing a fatal error. It's possible to specify a default value as well as individual values for specific error codes. See the docs for an overview of the various error codes.
    var meisterPlayer = new Meister('#player', {
        Shaka: {
            maxErrorCounts: {
                default: 5,
                1003: 1,
            }
        },
    });
    • [optional] default :: Number
      When no maximum has been set for a specific error code the player will use this value as the maximum number. Defaults to 3.
    • [optional] :: Number
      By entering a maximum for a specific error code it's possible to finetune the experience based on your needs. This makes it possible to throw an error after 1 request timeout retry by while keeping the other maximums higher:
  • [optional] shakaConfig :: Object
    Through this option it is possible to set default values in the Shaka player configuration. This object is directly passed to the configure call of the Shaka instance. These options can be overridden on a per item basis by setting a shakaConfig property on the item. See the docs for information on the configuration object.
    var meisterPlayer = new Meister('#player', {
        Shaka: {
            shakaConfig: {
                manifest: {
                    availabilityWindowOverride: 200,
                },
            }
        },
    });

Item options

The following options can be added per item

startFromLive [Boolean] (default: false)

Start from the live edge this will bring the player as close as possible to the live edge.

meisterPlayer.setItem({
    src: 'https://example.com/secure/stream/manifest.mpd',
    startFromLive: true,
    type: 'mpd'
});

startFromBeginning [Boolean|Object] (default: false)

Start from the beginning of the live stream. (VOD streams will always begin from the beginning).

meisterPlayer.setItem({
    src: 'https://example.com/secure/stream/manifest.mpd',
    startFromBeginning: true,
    type: 'mpd'
});

Or you can give an object with an offset to start from a offset

meisterPlayer.setItem({
    src: 'https://example.com/secure/stream/manifest.mpd',
    startFromBeginning: {
        offset: 10, // Start from the "beginning" with an offset of 10 seconds
    },
    type: 'mpd'
});

shakaConfig [Object] (default: {})

Through this option it is possible to set override default values in the Shaka player configuration on a per item basis. This object is directly passed to the configure call of the Shaka instance. See the docs for information on the configuration object.

meisterPlayer.setItem({
    src: 'https://example.com/secure/stream/manifest.mpd',
    shakaConfig: {
        manifest: {
            availabilityWindowOverride: 100,
        },
    }
    type: 'mpd'
});

customFilters [Array] (default: []])

While using Shaka for playback of DRM encrypted content there are two extra fields you can add to the Widevine or PlayReady config of the drmConfig object. These fields allow adding custom request and response filters as per the Shaka documentation.

meisterPlayer.setItem({
    src: 'https://example.com/secure/stream/manifest.mpd',
    drmConfig: {
        widevine: {
            customRequestFilters: [(type, request) => {
                if (type === shaka.net.NetworkingEngine.RequestType.LICENSE) {
                    const originalBody = request.body;
                    const newBody = {
                        licenseChallenge: originalBody;
                    }
                    request.body = JSON.stringify(newBody);
                }
            }],
            customResponseFilters: [(type, response) => {
                if (type === shaka.net.NetworkingEngine.RequestType.LICENSE) {
                    const originalResponse = response.data;
                    const license = originalResponse.licenseKey;
                    response.data = license;
                }
            }],
        },
    }
    type: 'mpd'
});