Skip to content

Commit

Permalink
Fix main server crah where subtitles where requested on the server in…
Browse files Browse the repository at this point in the history
…stead of the client (#84)
  • Loading branch information
GustavPS authored Mar 25, 2022
1 parent 19dfebf commit cb584c8
Showing 1 changed file with 24 additions and 25 deletions.
49 changes: 24 additions & 25 deletions Main Server/components/hlsPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,27 +86,6 @@ export default class HlsPlayer extends Component {
if (runningOnClient) {
this.chromecastHandler = new cheomecastHandler(this.chromecastProgressUpdate, this.chromecastDisconnect);
}

this.getSubtitles();
this.getLanguages()
.then(() => {
this.getResolutions().then(resolutions => {
const directplay = resolutions[0].name === "Directplay";
this.setState({
resolutions: resolutions,
activeResolutionLevel: resolutions.length - 1,
usingDirectplay: directplay
}, () => {
this.getSrc(directplay).then(src => {
this.chromecastHandler.setSrc(src); // TODO: Test
if (this._ismounted) {
this.setupHls();
}
})
});

});
});
}

/**
Expand Down Expand Up @@ -637,6 +616,30 @@ export default class HlsPlayer extends Component {
}

componentDidMount() {
// TODO: Make this readable..
this.getSubtitles();
this.getLanguages()
.then(() => {
this.getResolutions().then(resolutions => {
const directplay = resolutions[0].name === "Directplay";
this.setState({
resolutions: resolutions,
activeResolutionLevel: resolutions.length - 1,
usingDirectplay: directplay
}, () => {
this.getSrc(directplay).then(src => {
this.chromecastHandler.setSrc(src); // TODO: Test
this.setupHls();
})
});

});
});





// Check the localStorage if the chromecast API has already been loaded, if not, load it
let runningOnClient = typeof window !== "undefined";
if (runningOnClient && window["gCastIncluded"] == null) {
Expand All @@ -651,10 +654,6 @@ export default class HlsPlayer extends Component {
});

this._ismounted = true;
// If we have found the language, we can setup HLS. If not we will wait for the language to be found
if (Hls.isSupported() && this.state.activeLanguageStreamIndex !== null) {
this.setupHls();
}
this.soundBar.value = 100;
this.seekBar.value = 0;
this.pingInterval = setInterval(this.ping, 5000);
Expand Down

0 comments on commit cb584c8

Please sign in to comment.