diff --git a/README.md b/README.md index e0cbcfdb..f1a115aa 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,7 @@ Prop | Description `soundcloudConfig` | Configuration object for the SoundCloud player.
Set `clientId` to your own SoundCloud app [client ID](https://soundcloud.com/you/apps).
Set `showArtwork` to `false` to not load any artwork to display. `vimeoConfig` | Configuration object for the Vimeo player.
Set `iframeParams` to override the [default params](https://developer.vimeo.com/player/embedding#universal-parameters).
Set `preload` for [preloading](#preloading). `youtubeConfig` | Configuration object for the YouTube player.
Set `playerVars` to override the [default player vars](https://developers.google.com/youtube/player_parameters?playerVersion=HTML5).
Set `preload` for [preloading](#preloading). +`vidmeConfig` | Configuration object for the Vidme player.
Set `format` to use a certain quality of video, when available.
Possible values: `240p`, `480p`, `720p`, `1080p`, `dash`, `hls` `fileConfig` | Configuration object for the file player.
Set `attributes` to apply [element attributes](https://developer.mozilla.org/en/docs/Web/HTML/Element/video#Attributes). ##### Preloading diff --git a/src/ReactPlayer.js b/src/ReactPlayer.js index 56486cc0..7cbed6d4 100644 --- a/src/ReactPlayer.js +++ b/src/ReactPlayer.js @@ -108,7 +108,7 @@ export default class ReactPlayer extends Component { } renderPlayer = Player => { const active = Player.canPlay(this.props.url) - const { youtubeConfig, soundcloudConfig, vimeoConfig, fileConfig, ...activeProps } = this.props + const { youtubeConfig, soundcloudConfig, vimeoConfig, vidmeConfig, fileConfig, ...activeProps } = this.props const props = active ? { ...activeProps, ref: this.ref } : {} return ( diff --git a/src/players/Vidme.js b/src/players/Vidme.js index 26e7f5f0..60e2c5f6 100644 --- a/src/players/Vidme.js +++ b/src/players/Vidme.js @@ -26,12 +26,24 @@ export default class Vidme extends FilePlayer { } }) } + getURL ({ video }) { + const { vidmeConfig } = this.props + if (vidmeConfig.format && video.formats && video.formats.length !== 0) { + const index = video.formats.findIndex(f => f.type === vidmeConfig.format) + if (index !== -1) { + return video.formats[index].uri + } else { + console.warn(`Vidme format "${vidmeConfig.format}" was not found for ${video.full_url}`) + } + } + return video.complete_url + } load (url) { const { onError } = this.props this.stop() this.getData(url).then(data => { if (!this.mounted) return - this.player.src = data.video.complete_url + this.player.src = this.getURL(data) }, onError) } } diff --git a/src/props.js b/src/props.js index a06bdcbe..97dfdec6 100644 --- a/src/props.js +++ b/src/props.js @@ -28,6 +28,9 @@ export const propTypes = { iframeParams: object, preload: bool }), + vidmeConfig: shape({ + format: string + }), fileConfig: shape({ attributes: object }), @@ -65,6 +68,9 @@ export const defaultProps = { iframeParams: {}, preload: false }, + vidmeConfig: { + format: null + }, fileConfig: { attributes: {} },