Closed GenGol closed 1 year ago
The above commit should fix this.
Turns out, explicitly calling gl.getExtension('WEBGL_lose_context').loseContext()
to destroy the WebGL context is not a good idea. loseContext()
should only be used to "simulate" the glcontextlost
event. So I have removed this functionality from the WebGL .destroy()
method.
Furthermore, the canvas element is only removed from the document when calling .destroy()
if it was created by the renderer. If the canvas element was handed over to the renderer (through the options.canvas
in the Player constructor), it is left alone.
So, with this you can destroy()
and re-create a JSMpeg.Player
with the same canvas element, provided that it uses the same rendering method (2d or WebGL) as before.
I figured there was probably more to it. I've been testing these changes and so far so good. I haven't noticed any issues. Thank you for your help and efforts!!
I'm using JSMpeg using websockets. Player works fine the first time using a webSocket URL. I then I call player.destroy() which works fine.
BUT when I try to call JSMpeg.Player(webSocketURL, options) again I get the following error:
I've gone into the code and commented out the renderer.destroy() and it works fine:
This is what my instantiation of the player looks like:
Is there some other way I should be doing this?