Skip to content

Commit

Permalink
Add showPreview instance method
Browse files Browse the repository at this point in the history
  • Loading branch information
albanqoku committed Aug 10, 2019
1 parent 183895d commit a56dde5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ Method | Description
`getSecondsLoaded()` | Returns the number of seconds that have been loaded<br />&nbsp;&nbsp;Returns `null` if unavailable or unsupported
`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<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<br />&nbsp;&nbsp;Returns `null` if the internal player is unavailable
`showPreview()` | When using `light` mode, returns to the preview overlay

### Advanced Usage

Expand Down
3 changes: 3 additions & 0 deletions src/ReactPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export default class ReactPlayer extends Component {
onClickPreview = () => {
this.setState({ showPreview: false })
}
showPreview = () => {
this.setState({ showPreview: true })
}
getDuration = () => {
if (!this.player) return null
return this.player.getDuration()
Expand Down
3 changes: 3 additions & 0 deletions src/demo/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ class App extends Component {
<button onClick={this.stop}>Stop</button>
<button onClick={this.playPause}>{playing ? 'Pause' : 'Play'}</button>
<button onClick={this.onClickFullscreen}>Fullscreen</button>
{light &&
<button onClick={() => this.player.showPreview()}>Show preview</button>
}
{ReactPlayer.canEnablePIP(url) &&
<button onClick={this.togglePIP}>{pip ? 'Disable PiP' : 'Enable PiP'}</button>
}
Expand Down

0 comments on commit a56dde5

Please sign in to comment.