Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ThorSmallice opened this issue Aug 9, 2023 · 0 comments
Open

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

ThorSmallice opened this issue Aug 9, 2023 · 0 comments

Comments

@ThorSmallice
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant