bilibili / flv.js

HTML5 FLV Player
Apache License 2.0
22.83k stars 3.38k forks source link

React 中使用 load()方法报错unhandled error . #799

Open ThorSmallice opened 11 months ago

ThorSmallice commented 11 months ago

import flvjs from 'flv.js'; import { useEffect, useRef } from 'react'; const FlvPlayer = (props: any) => { const videoRef = useRef(null);

useEffect(() => { const videoElement = videoRef.current; const flvPlayer = flvjs.createPlayer({ type: 'flv', url: props.url });

if (flvjs.isSupported()) {
  flvPlayer.attachMediaElement(videoElement);
  flvPlayer.load();
}

return () => {
  if (flvPlayer) {
    flvPlayer.destroy();
  }
};

}, [props.url]);

return

export default FlvPlayer;

image