React js switch video sources error comes in Dash.js

1k views Asked by At

I am working on reactjs project with dashjs for playing video files. when I switch the videos getting following errors in attachView() function.

console click here for more details following code I am using : componentWillReceiveProps(nextProps) {

//console.log("nextprops", nextProps);
this.setState({ show: false });
setTimeout(function () { this.setState({ show: true }); }.bind(this), 500)

if (this.state.show && !nextProps.safari && nextProps.videoURL && nextProps.videoURL !== this.props.videoURL) {

    setTimeout(function () {
this.player.reset();
      this.player.attachView(this.video);
      this.player.attachSource(nextProps.videoURL);
      this.setState({ volume: this.player.getVolume() });
   }.bind(this), 2000)

}

}

1

There are 1 answers

1
Anonymous Coward On

This looks like a bug (or at least a deficiency with the documentation) with dash.js - you should open a new issue at https://github.com/Dash-Industry-Forum/dash.js/issues.

EDIT: This has been fixed as of dash.js v2.8.0.

In the meantime, for your use case where it looks like this.video doesn't change between calls, you can probably remove the calls to reset and attachView and just call attachSource with the new nextProps.videoURL. Note that you would obviously still need to call attachView (or initialize) at least once to attach this.video.