shiyiya / oplayer

:zap: Another HTM5 video player.
https://oplayer.vercel.app
MIT License
147 stars 19 forks source link

React component throw Uncaught TypeError: Cannot set properties of undefined (setting 'playbackRate') while loading. #91

Closed leopku closed 1 year ago

leopku commented 1 year ago

Environment

🐛 Bug Report

A new project with react component throw Uncaught TypeError: Cannot set properties of undefined (setting 'playbackRate') while loading.

To Reproduce

Steps to reproduce the behavior:


import Player from "@oplayer/core";
import ReactPlayer, { Source } from "@oplayer/react";
import hls from "@oplayer/hls";
import ui from "@oplayer/ui";
import { useRef } from "react";

const plugins = [
  ui(),
  hls(),
];

export default function OPlayer(
  { source = { src: "", poster: "" } }: {
    source: Source;
  },
) {
  const player = useRef<Player>(null);

  return (
    <ReactPlayer
      plugins={plugins}
      ref={player}
      aspectRatio={0}
      autoplay={false}
      source={source}
    />
  );
}

Expected behavior

An old project with same codes but old version of oplayer works fine.

    "@oplayer/core": "^1.2.11",
    "@oplayer/hls": "^1.2.8",
    "@oplayer/react": "^1.2.5",
    "@oplayer/ui": "^1.2.17",

Link to repl or repo (highly encouraged)

Please provide a minimal repository on GitHub.

Issues without a reproduction link are likely to stall.

shiyiya commented 1 year ago

off react strict mode

leopku commented 1 year ago

Got it.