Skip to content

Commit

Permalink
Make force disabling PIP dependent on prop (#964)
Browse files Browse the repository at this point in the history
* Make force disabling PIP dependent on prop

* Rename to stopOnUnmount (true by default)

Co-authored-by: Pete Cook <pete@cookpete.com>
  • Loading branch information
foysalit and cookpete authored Jul 23, 2020
1 parent 0aa2dee commit 5804bfb
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ Prop | Description | Default
`progressInterval` | The time between `onProgress` callbacks, in milliseconds | `1000`
`playsinline` | Applies the `playsinline` attribute where supported | `false`
`pip` | Set to `true` or `false` to enable or disable [picture-in-picture mode](https://developers.google.com/web/updates/2018/10/watch-video-using-picture-in-picture)<br/>&nbsp;&nbsp;Only available when playing file URLs in [certain browsers](https://caniuse.com/#feat=picture-in-picture) | `false`
`stopOnUnmount` | If you are using `pip` you may want to use `stopOnUnmount={false}` to continue playing in picture-in-picture mode even after ReactPlayer unmounts | `true`
`wrapper` | Element or component to use as the container element | `div`
`playIcon` | Element or component to use as the play icon in light mode
`config` | Override options for the various players, see [config prop](#config-prop)
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export interface ReactPlayerProps {
progressInterval?: number;
playsinline?: boolean;
pip?: boolean;
stopOnUnmount?: boolean;
light?: boolean | string;
wrapper?: any;
config?: Config;
Expand Down
2 changes: 1 addition & 1 deletion src/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class Player extends Component {
componentWillUnmount () {
clearTimeout(this.progressTimeout)
clearTimeout(this.durationCheckTimeout)
if (this.isReady) {
if (this.isReady && this.props.stopOnUnmount) {
this.player.stop()

if (this.player.disablePIP) {
Expand Down
2 changes: 2 additions & 0 deletions src/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const propTypes = {
progressInterval: number,
playsinline: bool,
pip: bool,
stopOnUnmount: bool,
light: oneOfType([bool, string]),
playIcon: node,
wrapper: oneOfType([
Expand Down Expand Up @@ -101,6 +102,7 @@ export const defaultProps = {
progressInterval: 1000,
playsinline: false,
pip: false,
stopOnUnmount: true,
light: false,
wrapper: 'div',
config: {
Expand Down

0 comments on commit 5804bfb

Please sign in to comment.