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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@twilio/live-player-sdk

v1.0.2

Published

Twilio Live Player JavaScript Library

Readme

twilio-live-player.js

CircleCI

The Twilio Live Player SDK allows you to play back a live stream of a Video Room. Please take a look at the SDK documentation here.

License

The Twilio Live Player SDK is distributed under the Twilio Terms of Service.

Browser Support

| | Chrome | Edge (Chromium) | Firefox | Safari | |---|---|---|---|---| | Android | ✓ * | - | - | - | | iOS | ✓ * | - | - | ✓ * | | Linux | ✓ | ✓ | ✓ | ✓ | | MacOS | ✓ | ✓ | ✓ * | ✓ | | Windows | ✓ | ✓ | ✓ * | ✓ |

Prerequisites

Installing the SDK

NPM

You can install the SDK as a dependency of your app by running the following command:

npm install @twilio/live-player-sdk

You can now import the SDK to your project as shown below:

TypeScript or ES Modules

import { Player } from '@twilio/live-player-sdk';

CommonJS

const { Player } = require('@twilio/live-player-sdk');

<script> tag

You can deploy node_modules/@twilio/live-player-sdk/dist/build/twilio-live-player.min.js with your application. Once you include it in a <script> tag, you can access the SDK APIs in window scope as shown below:

const { Player } = Twilio.Live;

Live Streaming a Video Room

Please refer to the Twilio Live docs docs for starting a live stream of a Video Room from your application server. At the end, you will have an AccessToken which you can use to join the live stream.

Checking for Browser Support

You can check whether the SDK supports the browser on which the application is running as shown below:

import { Player } from '@twilio/live-player-sdk';

if (Player.isSupported) {
  /**
   * Load your application.
   */
} else {
  /**
   * Inform the user that the browser is not supported.
   */
}

Joining a Live Stream

You can now join the live stream from your application using the AccessToken as shown below:

import { Player } from '@twilio/live-player-sdk';

const {
  host,
  protocol,
} = window.location;

/**
 * Join a live stream.
 */
const player = await Player.connect('$accessToken', {
  playerWasmAssetsPath: `${protocol}//${host}/path/to/hosted/player/assets`,
});

In order for the SDK to run, your application must host the following artifacts which are available in node_modules/@twilio/live-player-sdk/dist/build:

  • twilio-live-player-wasmworker-x-y-z.min.wasm
  • twilio-live-player-wasmworker-x-y-z.min.js

where x.y.z is the version of the SDK assets.

Handling Player Events

After joining the live stream, you can listen to events on the Player as shown below:

player.on(Player.Event.StateChanged, (state: Player.State) => {
  switch (state) {
    case Player.State.Buffering:
      /**
       * The player is buffering content.
       */
    case Player.State.Ended:
      /**
       * The stream has ended.
       */
    case Player.State.Idle:
      /**
       * The player has successfully authenticated and is loading the stream. This
       * state is also reached as a result of calling player.pause().
       */
    case Player.State.Playing:
      /**
       * The player is now playing a stream. This state occurs as a result of calling
       * player.play().
       */
    case Player.State.Ready:
      /**
       * The player is ready to play back the stream.
       */
  }
});

Live Stream Playback

You can perform the following playback actions on the live stream:

/**
 * Call this method after the Player transitions to the Player.State.Ready state.
 */
player.play();

/**
 * Pause playback.
 */
player.pause();

/**
 * Mute audio.
 */
player.isMuted = true;

/**
 * Unmute audio.
 */
player.isMuted = false;

/**
 * Set volume.
 */
player.setVolume(0.5);

Handling the Browser's Autoplay Policy

If your application plays the live stream on page load without a user action, then the browser's autoplay policy may come into effect, in which case the audio will be muted. You can detect when this happens by listening to the Player.Event.VolumeChanged event on the Player as shown below:

player.on(Player.Event.VolumeChanged, () => {
  if (player.isMuted) {
    /**
     * Show the unmute button.
     */
  } else {
    /**
     * Hide the unmute button.
     */
  }
});

Rendering the Live Stream

In order to render the live stream, you can use the default HTMLVideoElement created by the Player in your application as shown below:

const container = document.querySelector('div#container');
container.appendChild(player.videoElement);

Alternatively, if you want to render the live stream in your own HTMLVideoElement, you can do so as shown below:

const videoElement = document.querySelector('div#container > video');
/**
 * Enable inline playback on iOS browsers.
 */
videoElement.playsInline = true;
player.attach(videoElement);

Handling Timed Metadata

When a Media Extension inserts TimedMetadata into a stream, you can receive them by listening to the Player.Event.TimedMetadataReceived event as shown below:

player.on(Player.Event.TimedMetadataReceived, (metadata: Player.TimedMetadata) => {
  /**
   * Handle the metadata.
   */
});

Disconnecting from the Live Stream

You can disconnect from the live stream as shown below:

player.disconnect();

This is a terminal operation on the Player, which is no longer useful to the application.

Known Issues

Android Chrome

  • Cannot resume playback of a paused live stream.
  • The video of a live stream sometimes flickers.

Desktop Firefox

  • The Player takes a few seconds longer than usual to reach the ended state after a live stream is stopped by ending a MediaProcessor.

iOS Chrome

  • The parameters of Player.stats are always either 0 or null.
  • Cannot change the volume of a live stream's audio.
  • The live latency of a stream is sometimes greater than 3 seconds.

iOS Safari

  • The parameters of Player.stats are always either 0 or null.
  • Cannot change the volume of a live stream's audio.
  • The live latency of a stream is sometimes greater than 3 seconds.