devcshort / react-hls

Simple React component for playing hls/rtmp live streams.
https://www.npmjs.com/package/react-hls-player
MIT License
120 stars 48 forks source link

type error: this._initPlayer not defined #2

Closed aaplmike closed 4 years ago

aaplmike commented 4 years ago

Hello. Thanks for publishing this module! I'm attempting to use it in a create-react app and get this error when loading the component. Using the URL directly in the browser plays the stream, however using the same exact URL in my component's render function I get that error.

import React from 'react'; import ReactHLS from 'react-hls-player';

class VideoPlayer extends React.Component {

render() { return( <ReactHLS url="http://example.com:8080/hls/stream.m3u8" /> ); } }

devcshort commented 4 years ago

Hey @aaplmike!

I'll take a look in to this. In the meantime, would you be able to provide me with your full code example, as well as your React version and stream URL you are trying to load?

Thanks 😄

simas-dev commented 4 years ago

Hi, I have set enableWorker option to false and that error went away. hlsConfig ={{ enableWorker: false, }}

more details: https://github.com/video-dev/hls.js/issues/2064

devcshort commented 4 years ago

Thanks @sonikas991

Looks like this is potentially an issue with a compatibility between hls.js and React. I'll keep a close eye on the thread and apply an update when one becomes available.

devcshort commented 4 years ago

https://github.com/devcshort/react-hls/commit/e027df018652e9554da4f6cac44b0a8145df8cdb Disable worker option by default to avoid errors until HLS team pushes a fix.