reload

Description

Re-load the last loaded content as fast as possible.

This API can be called at any time after a content has been loaded (the LOADED state has been reached), even if the player has been stopped since and even if it was due to a fatal error.

The user may need to call this API in several cases. For example, it may be used in case of an error that will not reproduce or inversely when the error is consistent at a certain playback time (e.g. due to a specific chunk defect).

The options argument is an object containing :

  • reloadAt (Object | undefined): The object contain directives about the starting playback position :
    • relative (string | undefined) : start playback relatively from the last playback position (last played position before entering into STOPPED or ENDED state).
    • position (string|undefined) : absolute position at which we should start playback

If no reload position is defined, start playback at the last playback position.

Note that despite this method’s name, the player will not go through the RELOADING state while reloading the content but through the regular LOADING state - as if loadVideo was called on that same content again.

Syntax

// without options
player.reload();

// or with options
player.reload(options)`
  • arguments:

    1. options (optional) Object | undefined: Optional requirements, e.g. at which position the player should reload.

Example

player.addEventListener("error", (error) => {
  if (error.code === "BUFFER_APPEND_ERROR") {
    // Try to reload after the last playback position, in case of defectuous
    // media content at current time.
    player.reload({ reloadAt: { relative: +5 } });
  } else {
    // Try to reload at the last playback position
    player.reload();
  }
});
Page List