# Class: MediaPreloader

## MediaPreloader

#### new MediaPreloader(options)

  Preload audio and video

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---

  `options`

  Object

  ###### Properties

  Name | Type | Argument | Description
  --- | --- | --- | ---
  `$media` | HTMLElement |  |
  `onProgress` | mediaPreloader_Callback | <optional> |

  ##### Example

      let mp = new MediaPreloader(
                  {
                      "$media": $myVideo,
                      "onProgress": percent => {
                       }
                  }
              )
              .then( handler )
              .catch( handler );

      // Must start the load manually
      mp.startLoad();

      // Browser capability
      allowMP4 = MediaPreloader.videoCanPlayType.mp4;
      allowWEBM = MediaPreloader.videoCanPlayType.WEBM;
      allowMP3 = MediaPreloader.videoCanPlayType.mp3;

      MediaPreloader.getUrl( '/path/my-video' ) // => '/path/my-video.mp4' if the browser use mp4

### Members

#### <static> videoCanPlayType :MediaPreloader_PlayType

  Browser play capabilities

  ##### Type:

  - MediaPreloader_PlayType

### Methods

#### <static> getUrl(url)

  Add the correct extention depending on the browser capability

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `url` | String | File name without extention

  ##### Returns:

  Type
    String

#### startLoad()

  Start the preload of the media

  ##### Returns:

  Type
    Promise

### Type Definitions

#### mediaPreloader_Callback(percent)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `percent` | Number |

#### MediaPreloader_PlayType

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `mp4` | Boolean |
  `webm` | Boolean |
  `mp3` | Boolean |

#### Search results