@oplayer/react
TypeScript icon, indicating that this package has built-in type declarations

1.2.11-beta.1 • Public • Published

oplayer-plugin-react

npm npm bundle size npm dm jsdelivr

React wrapper for oplayer. (NOT WORKING ON REACT STRICT MODE)

Install

npm i @oplayer/core @oplayer/react
import ReactPlayer from '@oplayer/react'

const plugins = [
  ui({
    pictureInPicture: true,
    slideToSeek: 'always',
    screenshot: true,
    keyboard: { global: true }
  }),
  hls()
]

function playPage() {
  const [source, setSource] = useState<any>()
  const player = useRef<Player>(null)

  useEffect(() => {
    setSource(
      // Be a Promise or raw
      fetch(`xxxx`).then((it) => {
        return it
      })
    )
  }, [lastEpisode])

  return (
    <>
      <h1>Now Playing "君の名は"</h1>

      <ReactPlayer
        plugins={plugins}
        ref={player}
        autoplay={true}
        source={source}
        duration={lastDuration}
        isLive={id == 'iptv'}
        onEvent={(e) => {}}
      />
    </>
  )
}

Readme

Keywords

Package Sidebar

Install

npm i @oplayer/react

Weekly Downloads

27

Version

1.2.11-beta.1

License

MIT

Unpacked Size

14.3 kB

Total Files

8

Last publish

Collaborators

  • isbailin