Skip to content

Commit

Permalink
Add support for twitch player options
Browse files Browse the repository at this point in the history
Fixes #343
  • Loading branch information
cookpete committed Mar 15, 2018
1 parent dcf3b88 commit 61c058e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ Key | Options
`wistia` | `options`: Override the [default player options](https://wistia.com/doc/embed-options#options_list)
`mixcloud` | `options`: Override the [default player options](https://www.mixcloud.com/developers/widget/#methods)
`dailymotion` | `params`: Override the [default player vars](https://developer.dailymotion.com/player#player-parameters)<br />`preload`: Used for [preloading](#preloading)
`twitch` | `options`: Override the [default player options](https://dev.twitch.tv/docs/embed)
`file` | `attributes`: Apply [element attributes](https://developer.mozilla.org/en/docs/Web/HTML/Element/video#Attributes)<br />`forceAudio`: Always render an `<audio>` element<br />`forceHLS`: Use [hls.js](https://github.com/video-dev/hls.js) for HLS streams<br />`forceDASH`: Always use [dash.js](https://github.com/Dash-Industry-Forum/dash.js) for DASH streams<br />`hlsOptions`: Override the [default `hls.js` options](https://github.com/video-dev/hls.js/blob/master/doc/API.md#fine-tuning)

##### Preloading
Expand Down
5 changes: 3 additions & 2 deletions src/players/Twitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class Twitch extends Component {
callPlayer = callPlayer
playerID = PLAYER_ID_PREFIX + randomString()
load (url, isReady) {
const { playsinline, onError } = this.props
const { playsinline, onError, config } = this.props
const isChannel = MATCH_CHANNEL_URL.test(url)
const id = isChannel ? url.match(MATCH_CHANNEL_URL)[1] : url.match(MATCH_VIDEO_URL)[1]
if (isReady) {
Expand All @@ -35,7 +35,8 @@ export class Twitch extends Component {
height: '100%',
width: '100%',
playsinline: playsinline,
autoplay: this.props.playing
autoplay: this.props.playing,
...config.twitch.options
})
const { READY, PLAY, PAUSE, ENDED } = Twitch.Player
this.player.addEventListener(READY, this.props.onReady)
Expand Down
6 changes: 6 additions & 0 deletions src/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ export const propTypes = {
}),
mixcloud: shape({
options: object
}),
twitch: shape({
options: object
})
}),
onReady: func,
Expand Down Expand Up @@ -133,6 +136,9 @@ export const defaultProps = {
options: {
hide_cover: 1
}
},
twitch: {
options: {}
}
},
onReady: function () {},
Expand Down

0 comments on commit 61c058e

Please sign in to comment.