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

@college-africa/videojs-shaka

v1.1.3

Published

Updated video.js shaka player tech

Downloads

16

Readme

videojs-shaka

This is an updated fork of videojs-shaka

Table of Contents

Installation

npm install --save videojs-shaka

Usage

To include videojs-shaka on your website or web application, use any of the following methods.

<script> Tag

This is the simplest case. Get the script in whatever way you prefer and include the plugin after you include video.js, so that the videojs global is available.

<script src="//path/to/shaka-player.compiled.js"></script>
<script src="//path/to/video.min.js"></script>
<script src="//path/to/videojs-shaka.min.js"></script>
<script>
  var player = videojs('my-video', {
    techOrder: ['shaka'],
    ...
  });
  player.src([{
    type: 'application/dash+xml',
    src: '//path/to/some.mpd'
  }]);
</script>

If you want to enable the bitrate quality picker menu, you'll need to initialize it by calling the qualityPickerPlugin function.

<script>
  var player = videojs('my-video', {
    techOrder: ['shaka'],
    ...
  });

  player.qualityPickerPlugin();
  player.src([{
    type: 'application/dash+xml',
    src: '//path/to/some.mpd'
  }]);
</script>

Debug

Configure DEBUG logging level in the following manner by including the shaka-player.compiled.debug.js on your page (default will be set to ERROR):

<script src="//path/to/shaka-player.compiled.debug.js"></script>
<script src="//path/to/video.min.js"></script>
<script src="//path/to/videojs-shaka.min.js"></script>
<script>
  var player = videojs('my-video', {
    techOrder: ['shaka'],
    shaka: {
      debug: true
      configuration: {
        // shaka player configuration - https://shaka-player-demo.appspot.com/docs/api/tutorial-config.html
      }   
    }
    ...
  });

  player.qualityPickerPlugin();
  player.src([{
    type: 'application/dash+xml',
    src: '//path/to/some.mpd'
  }]);
</script>

Sideloading Subtitles/Captions

There may be times when you have embedded subtitles in your stream, but you want to side load webvtt files into video.js yourself. Just specify sideload: true and the embedded subtitles in the stream will be ignored (default will be set to false).

<script src="//path/to/shaka-player.compiled.debug.js"></script>
<script src="//path/to/video.min.js"></script>
<script src="//path/to/videojs-shaka.min.js"></script>
<script>
  var player = videojs('my-video', {
    techOrder: ['shaka'],
    shaka: {
      debug: false,
      sideload: true,
      configuration: {
        // shaka player configuration - https://shaka-player-demo.appspot.com/docs/api/tutorial-config.html
      }   
    }
    ...
  });

  player.qualityPickerPlugin();
  player.src([{
    type: 'application/dash+xml',
    src: '//path/to/some.mpd'
  }]);
</script>

DRM

Configure DRM in the following manner:

<script>
  var player = videojs('my-video', {
    techOrder: ['shaka'],
    shaka: {
      configuration: {
        drm: {
          servers: {
            'com.widevine.alpha': 'https://foo.bar/drm/widevine'
          }
        },    
      }
      licenseServerAuth: function(type, request) {
        // Only add headers to license requests:
        if (type == shaka.net.NetworkingEngine.RequestType.LICENSE) {
          // This is the specific header name and value the server wants:
          request.headers['CWIP-Auth-Header'] = 'VGhpc0lzQVRlc3QK';
          // This is the specific parameter name and value the server wants:
          // Note that all network requests can have multiple URIs (for fallback),
          // and therefore this is an array. But there should only be one license
          // server URI in this tutorial.
          request.uris[0] += '?CWIP-Auth-Param=VGhpc0lzQVRlc3QK';
        }
      }
    }
    ...
  });

  player.qualityPickerPlugin();
  player.src([{
    type: 'application/dash+xml',
    src: '//path/to/some.mpd'
  }]);
</script>

If you need to set the DRM server after you initialize video.js prior to loading the source, you can specify a function for shaka.configuration.drm as follows:

<script>
  var player = videojs('my-video', {
    techOrder: ['shaka'],
    shaka: {
      configuration: {
        drm: function() {
          // return the object here like
          return {
            servers: {
              'com.widevine.alpha': 'https://foo.bar/drm/widevine'
            }
          }
        }
      }
    }
    ...
  });

  player.qualityPickerPlugin();
  player.src([{
    type: 'application/dash+xml',
    src: '//path/to/some.mpd'
  }]);
</script>

qualitytrackchange Event

If you would like to know when a user switches video quality, you can register an event listener for qualitytrackchange. The quality track object will be returned to you.

<script>
  player.on('qualitytrackchange', function(event, track) {
    // do something with the track that was selected
  });
</script>

Sample App

To run the sample app, you just need to start the development server with the following command:

$ npm run sample

Then just open the app at http://localhost:3000/

Special Thanks

This library wasn't possible without leveraging the following libraries that were used to create this.

License

MIT. Copyright (c) Dave Herzog <[email protected]>