1.2.0 • Published 4 years ago

useaudiopictureinpicture v1.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

useAudioPictureInPicture

A react component that allow you to enable picture in picture mode on your audio player. The inspiration came from the open spotify player

Demo

NPM JavaScript Style Guide

Install

npm install --save useaudiopictureinpicture

or

yarn add useaudiopictureinpicture

Demo

You can find a demo of the package here

Todo

  • Browser compatibility indicator
  • any suggestion ...

Usage

import React, { Component } from 'react'

import { useAudioPictureInPicture } from 'useaudiopictureinpicture'

const Example = () => {
  //basic setup of the useAudioPictureInPicture hook
  const {isPipToggled, togglePip, updatePip} = useAudioPictureInPicture(initialImage, play, pause, previous, next)
}

(See the example directory for a complete example)

Parameters:

Parameterdescriptionrequired?default
initialImageFirst image to display when picture in picture mode is enabletruenull
onPlayFunction that would be trigger when the play button is pressed on the picture in picture framefalsenull
onPauseFunction that would be trigger when the pause button is pressed on the picture in picture framefalsenull
onPreviousFunction that would be trigger when the previous button is pressed on the picture in picture framefalsenull
onNextFunction that would be trigger when the next button is pressed on the picture in picture framefalsenull

Return:

NameTypeDescription
isPipToggledbooleanState that represent the toggle state of the picture in picture
togglePipfunctiontoggles state of PiP in document
updatePipfunctionsee reference here

License

MIT © Thomascogez


This hook is created using create-react-hook.