How to use the shaka-player.Player function in shaka-player

To help you get started, we’ve selected a few shaka-player examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bytedance / xgplayer / packages / xgplayer-shaka / src / index.js View on Github external
super(options)
    let self = this
    this.shakaOpts = options.shakaOpts || {}
    this.util = Player.util
    this.player = this
    this.url = this.player.config.url
    this.sniffer = Player.sniffer
    this.player_ = null
    this.content = []

    Shaka.polyfill.installAll()

    if (Shaka.Player.isBrowserSupported()) {
      this.video_ = this.player.video
      this.video_.autoplay = false
      this.player_ = new Shaka.Player(this.video_)

      this.player_.addEventListener('error', function (event) {
        console.error('Error code', event.detail.code, 'object', event.detail) // eslint-disable-line no-console
      })

      if (this.shakaOpts) {
        this.player_.configure(this.shakaOpts)
      }

      this.player_.getNetworkingEngine().registerRequestFilter(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'
        }
      })
github enactjs / samples / pattern-shaka-video-player / src / components / ShakaVideoPlayer.js View on Github external
initPlayer = () => {
			// Create a Player instance with videoNode.
			const player = new shaka.Player(this.videoNode);

			// Listen for error events.
			player.addEventListener('error', this.onErrorEvent);

			// Try to load a manifest.
			// This is an asynchronous process.
			player
				.load(this.props.manifestUri)
				.then(function () {
					// This runs if the asynchronous load is successful.
					console.log('The video has now been loaded!');
				})
				.catch(this.onError); // onError is executed if the asynchronous load fails.

			// Configuration for the player here
			// https://shaka-player-demo.appspot.com/docs/api/tutorial-config.html
github matvp91 / indigo-player / src / media / DashMedia / DashMedia.ts View on Github external
public async load() {
    await super.load();

    const mediaElement: HTMLMediaElement = (this.instance.getModule(
      'HTML5Player',
    ) as any).mediaElement;

    this.player = new shaka.Player(mediaElement);

    this.player.addEventListener('error', this.onErrorEvent.bind(this));
    this.player.addEventListener(
      'adaptation',
      this.onAdaptationEvent.bind(this),
    );

    this.emit(Events.SHAKA_INSTANCE, {
      shaka,
      player: this.player,
    } as IShakaInstEventData);

    const configuration: any = {
      abr: {
        enabled: true,
        defaultBandwidthEstimate:
github clappr / dash-shaka-playback / index.js View on Github external
_createPlayer() {
    var player = new shaka.Player(this.el)
    player.addEventListener('error', (type, shakaError) => this._error(type, shakaError))
    player.addEventListener('adaptation', () => this._onAdaptation())
    player.addEventListener('buffering', (e) => this._onBuffering(e))
    return player
  }
github clappr / dash-shaka-playback / src / clappr-dash-shaka-playback.js View on Github external
_createPlayer () {
    let player = new shaka.Player(this.el)
    player.addEventListener('error', this._onError.bind(this))
    player.addEventListener('adaptation', this._onAdaptation.bind(this))
    player.addEventListener('buffering', this._onBuffering.bind(this))
    return player
  }
github Eyevinn / html-player / src / playerTechs / dash_player.js View on Github external
return new Promise(resolve => {
      let shakap = new Shaka.Player(this.videoElement_);
      shakap.load(this.manifestUrl_).then(() => {
        resolve();
      });
      this.shakap_ = shakap;
    });
  }
github vimond / replay / src / replay / components / player / VideoStreamer / ShakaVideoStreamer / shakaSetup.js View on Github external
export function shakaSetup(
  videoElement: HTMLVideoElement,
  configuration: ?ShakaVideoStreamerConfiguration
): ShakaPlayer {
  if (!!window.MediaSource && !!MediaSource.isTypeSupported) {
    const shakaPlayerConfig = configuration && configuration.shakaPlayer;
    if (shakaPlayerConfig && shakaPlayerConfig.installPolyfills) {
      shaka.polyfill.installAll();
    }
    const shakaPlayer = new shaka.Player(videoElement);
    if (shakaPlayerConfig && shakaPlayerConfig.customConfiguration) {
      shakaPlayer.configure(shakaPlayerConfig.customConfiguration);
    }
    return shakaPlayer;
  } else {
    throw new PlaybackError(
      'STREAM_ERROR_TECHNOLOGY_UNSUPPORTED',
      'shaka',
      'MPEG-DASH playback with Shaka Player is not supported in this browser.'
    );
  }
}

shaka-player

DASH/EME video player library

Apache-2.0
Latest version published 9 days ago

Package Health Score

98 / 100
Full package analysis

Similar packages