shaka player never triggers 'error' listener

1k views Asked by At

I am integrating shaka player in my web application. I have gone throught the documentation and found basic program to load player with video manifest url. Link for basic program is basic tutorial. And it is loading video fine.

I need to implement error handing for player. So I am trying to understand, where the 'error' event listener will be firing. Following is the code for listening error. It is not triggering anymore for me.

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

Following are the Trails to get it invoked but not triggered: Trail 1: Not initialized video variable.

  const video = null;
  const player = new shaka.Player(video);

Trail 2: Loading an invalid manifest url.

try {
    await player.load('https://mydymmy.manifest.url');
  } catch (e) {
    onError(e);
  }

I would like to implement error handling in my program. For that i need to understand when this 'error' listener will be invoking.

2

There are 2 answers

1
RedLizardMan On

player.addEventListener('error', onErrorEvent);

The listener example in the tutorial didn't work


const listener = new shaka.util.EventManager();

listener.listen(player, error, (event: any) => { onErrorEvent(event); });

You should use shaka.util.EventManager

1
Will On

Hey I ran into this issue too and to help anyone else who runs into this issue, this is how you catch the error on load.

await player.load('https://mydymmy.manifest.url').catch(onError);

Hopefully that helps.