Skip to content

Commit

Permalink
When requesting quickly a change in the quality of a video, the
Browse files Browse the repository at this point in the history
HTMLVideoElement wasn't always ready and thus null. We tried to remove
some EventListener of something null, so it crashed. It is not the case
anymore, as a check on the HTMLVideoElement (either null or undefined)
is done.
  • Loading branch information
aberthet-gpsw committed May 16, 2017
1 parent eba82f0 commit 14c7c94
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/display/video/VideoHTML5.js
Original file line number Diff line number Diff line change
Expand Up @@ -1540,20 +1540,26 @@ FORGE.VideoHTML5.prototype._clearRequestedVideo = function()
{
//Remove all listeners used for the requested video
var element = video.element;
element.removeEventListener("loadstart", this._onRequestLoadStartBind, false);
element.removeEventListener("loadedmetadata", this._onRequestLoadedMetaDataBind, false);
element.removeEventListener("loadeddata", this._onRequestLoadedDataBind, false);
element.removeEventListener("play", this._onRequestCanPlayBeforeSeekBind, false);
element.removeEventListener("seeked", this._onRequestSeekedBind, false);
if (FORGE.Device.edge === true || FORGE.Device.ie === true)
{
element.removeEventListener("canplaythrough", this._onRequestCanPlayAfterSeekBind, false);
}
else

if (typeof element !== "undefined" && element !== null)
{
element.removeEventListener("canplay", this._onRequestCanPlayAfterSeekBind, false);
element.removeEventListener("loadstart", this._onRequestLoadStartBind, false);
element.removeEventListener("loadedmetadata", this._onRequestLoadedMetaDataBind, false);
element.removeEventListener("loadeddata", this._onRequestLoadedDataBind, false);
element.removeEventListener("play", this._onRequestCanPlayBeforeSeekBind, false);
element.removeEventListener("seeked", this._onRequestSeekedBind, false);

if (FORGE.Device.edge === true || FORGE.Device.ie === true)
{
element.removeEventListener("canplaythrough", this._onRequestCanPlayAfterSeekBind, false);
}
else
{
element.removeEventListener("canplay", this._onRequestCanPlayAfterSeekBind, false);
}

element.removeEventListener("error", this._onRequestErrorBind, false);
}
element.removeEventListener("error", this._onRequestErrorBind, false);

//Destroy the requested video
this._destroyVideo(video);
Expand Down

0 comments on commit 14c7c94

Please sign in to comment.