flv.js icon indicating copy to clipboard operation
flv.js copied to clipboard

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

Open ThorSmallice opened this issue 1 year ago • 0 comments

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 <video className={props?.className} ref={videoRef} controls />; };

export default FlvPlayer;

image

ThorSmallice avatar Aug 09 '23 06:08 ThorSmallice