A custom React hook to use Picture in Picture mode in supported browsers.
npm install use-pip
Feel free to replace with yarn counterparts.
const { loading, error, toggle } = usePip(videoRef);
See example directory for complete code.
Parameter | description | required? | default |
---|---|---|---|
videoRef | Ref for the video element | true | null |
Name | Type | Description |
---|---|---|
loading | boolean | Manages loading time for setting for detecting support |
error | string | Error state as described by spec. Holds value NotSupportedError if browser or video does not support attribute. |
toggle | function | toggles state of PiP in document |
- Install dependencies
npm install
- Run dev for lib
npm run dev
- Run demo
npm start