Skip to content

Commit 14c7c94

Browse files
committed
When requesting quickly a change in the quality of a video, the
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.
1 parent eba82f0 commit 14c7c94

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/display/video/VideoHTML5.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,20 +1540,26 @@ FORGE.VideoHTML5.prototype._clearRequestedVideo = function()
15401540
{
15411541
//Remove all listeners used for the requested video
15421542
var element = video.element;
1543-
element.removeEventListener("loadstart", this._onRequestLoadStartBind, false);
1544-
element.removeEventListener("loadedmetadata", this._onRequestLoadedMetaDataBind, false);
1545-
element.removeEventListener("loadeddata", this._onRequestLoadedDataBind, false);
1546-
element.removeEventListener("play", this._onRequestCanPlayBeforeSeekBind, false);
1547-
element.removeEventListener("seeked", this._onRequestSeekedBind, false);
1548-
if (FORGE.Device.edge === true || FORGE.Device.ie === true)
1549-
{
1550-
element.removeEventListener("canplaythrough", this._onRequestCanPlayAfterSeekBind, false);
1551-
}
1552-
else
1543+
1544+
if (typeof element !== "undefined" && element !== null)
15531545
{
1554-
element.removeEventListener("canplay", this._onRequestCanPlayAfterSeekBind, false);
1546+
element.removeEventListener("loadstart", this._onRequestLoadStartBind, false);
1547+
element.removeEventListener("loadedmetadata", this._onRequestLoadedMetaDataBind, false);
1548+
element.removeEventListener("loadeddata", this._onRequestLoadedDataBind, false);
1549+
element.removeEventListener("play", this._onRequestCanPlayBeforeSeekBind, false);
1550+
element.removeEventListener("seeked", this._onRequestSeekedBind, false);
1551+
1552+
if (FORGE.Device.edge === true || FORGE.Device.ie === true)
1553+
{
1554+
element.removeEventListener("canplaythrough", this._onRequestCanPlayAfterSeekBind, false);
1555+
}
1556+
else
1557+
{
1558+
element.removeEventListener("canplay", this._onRequestCanPlayAfterSeekBind, false);
1559+
}
1560+
1561+
element.removeEventListener("error", this._onRequestErrorBind, false);
15551562
}
1556-
element.removeEventListener("error", this._onRequestErrorBind, false);
15571563

15581564
//Destroy the requested video
15591565
this._destroyVideo(video);

0 commit comments

Comments
 (0)