Skip to content

Commit

Permalink
Make getInternalPlayer more flexible
Browse files Browse the repository at this point in the history
Fixes #238
  • Loading branch information
cookpete committed Sep 28, 2017
1 parent 1a7d3f3 commit f4fe862
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ Method | Description
`seekTo(amount)` | Seek to the given number of seconds, or fraction if `amount` is between `0` and `1`
`getCurrentTime()` | Returns the number of seconds that has been played<br />&nbsp;&nbsp;Returns `null` if duration is unavailable
`getDuration()` | Returns the duration (in seconds) of the currently playing media<br />&nbsp;&nbsp;Returns `null` if duration is unavailable
`getInternalPlayer()` | Returns the internal player of whatever is currently playing<br />&nbsp;&nbsp;eg the [YouTube player instance](https://developers.google.com/youtube/iframe_api_reference#Loading_a_Video_Player), or the [`<video>`](https://developer.mozilla.org/en/docs/Web/HTML/Element/video) element when playing a video file
`getInternalPlayer()` | Returns the internal player of whatever is currently playing<br />&nbsp;&nbsp;eg the [YouTube player instance](https://developers.google.com/youtube/iframe_api_reference#Loading_a_Video_Player), or the [`<video>`](https://developer.mozilla.org/en/docs/Web/HTML/Element/video) element when playing a video file<br />&nbsp;&nbsp;Use `getInternalPlayer('hls')` to get the [hls.js](https://github.com/video-dev/hls.js) player<br />&nbsp;&nbsp;Use `getInternalPlayer('dash')` to get the [dash.js](https://github.com/Dash-Industry-Forum/dash.js) player

### Supported media

Expand Down
4 changes: 2 additions & 2 deletions src/ReactPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ export default class ReactPlayer extends Component {
if (!this.player) return null
return this.player.getCurrentTime()
}
getInternalPlayer = () => {
getInternalPlayer = (key = 'player') => {
if (!this.player) return null
return this.player.player
return this.player[key]
}
progress = () => {
if (this.props.url && this.player && this.player.isReady) {
Expand Down
6 changes: 3 additions & 3 deletions src/players/FilePlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ export default class FilePlayer extends Base {
}
if (this.shouldUseDASH(url)) {
getSDK(DASH_SDK_URL, DASH_GLOBAL).then(dashjs => {
const player = dashjs.MediaPlayer().create()
player.initialize(this.player, url, true)
player.getDebug().setLogToBrowserConsole(false)
this.dash = dashjs.MediaPlayer().create()
this.dash.initialize(this.player, url, true)
this.dash.getDebug().setLogToBrowserConsole(false)
})
}
}
Expand Down

0 comments on commit f4fe862

Please sign in to comment.