video.js icon indicating copy to clipboard operation
video.js copied to clipboard

Get this error if I reload a page with a live stream on it.

Open billybobilly opened this issue 10 years ago • 5 comments

Uncaught InvalidStateError: MediaSource.addSeekableRange() can only be invoked when the duration is Infinity

I get the error when I reload the page on which I have a videojs player with a live stream HLS source. The duration IS Infinity, but this error is still thrown. Does not appear to happen on the first load of the live stream page, only after a page refresh.

billybobilly avatar Feb 14 '16 22:02 billybobilly

After digging and debugging a bit, it turns out that when that error is thrown the player isn't initialized yet. Apparently, whatever is leaving it in that uninitialized state can be forced to complete initialization by calling play().

So, the work around for when this happens is to call play() before the player.ready() function is invoked.

billybobilly avatar Feb 17 '16 04:02 billybobilly

Try player.load() instead.

gkatsev avatar Feb 17 '16 05:02 gkatsev

That was the first thing we tried a long time ago. No effect. The only thing we've found that causes it to fire .ready is to play()

billybobilly avatar Feb 17 '16 05:02 billybobilly

Hi!

Can you please elaborate on how to fix it exactly. Some code may be?

Thanks id advance.

MRamirez

moriciogithub avatar Mar 02 '16 23:03 moriciogithub

For me, adding in the src call and the play call after making sure videojs was ready worked. E.g my code now looks like:

this.brightcovePlayer = videojs(this.video).ready( () => {

  this.brightcovePlayer.src({
    src: program.high_res,
    type: 'application/x-mpegURL'
  });

  this.brightcovePlayer.play();
});

jonny-discovery avatar Aug 01 '16 11:08 jonny-discovery