Orange-OpenSource / hasplayer.js

Http Adaptive Streaming javascript player based on HTML5 premium extensions (MSE/EME)
Other
198 stars 67 forks source link

Integrate hasPlayer with React #203

Closed Visarion closed 5 years ago

Visarion commented 6 years ago

Hi! I'm trying to integrate the player with React. I downloaded the hasPlayer.js file in my /src, and i try to import it in my component (import MediaPlayer from "hasplayer/hasPlayer";). When i want to initialize it using the code you provided (in componentWillMount() method), i receive this error _TypeError: WEBPACK_IMPORTED_MODULE_4_hasplayerhasPlayerdefault.a is not a constructor_. Can you help me with it? Thank you!

Visarion commented 6 years ago

the code looks like this:

import MediaPlayer from "hasplayer/hasPlayer";

export default class Dev extends Component { componentWillMount() { var stream = { url: "http://playready.directtaps.net/smoothstreaming/SSWSS720H264/SuperSpeedway_720.ism/Manifest" }; var mediaPlayer = new MediaPlayer(); mediaPlayer.init(document.getElementById("videoPlayer")); mediaPlayer.load(stream); }

render() {

    return (
            <div>
                <video id="videoPlayer" controls="true"></video>
            </div>
    );
}

}

bbert commented 6 years ago

Hi, Did you try with minifed version of hasplayer (hasplayer.min.js)? There was an issue with this file since v1.13.0. Can you try with latest version (1.14.0)?

edgarmartinez922 commented 6 years ago

Hi Visarion Move ur code to componentDidMount