unable to show video after destroy()
surendragalwa11 opened this issue · 3 comments
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
https://github.com/surendragalwa111/jsmpeg-player-canvas/blob/master/src/App.js
Expected behavior
I have a checkbox to show and hide the video player.
- Initially checkbox is unchecked and video player doesn't render.
- When I check the checkbox, I'm able to see the rendered video screen.
- Now when I uncheck the checkbox to hide the video, I
destroy()
the player instance. This works fine but player instance remove all the childElements ofvideoWrapper
- Now when I again check the checkbox to render video player, it doesn't render at all.
WHY??
Thanks for your feedback, and sorry for replying so late. I just came back from vacation.
I think manually setting the width and height of the #canvasParent
element can solve your problem. Just add the following code in your Css.
#canvasParent {
width: 304px;
height: 158px;
}
But this is not the case.
JSMPEG player attaches an event to destroy the canvas and doesn't unbind the event after the canvas destroyed.
So when we re-render the canvas, the previously attached event again destroys the canvas.This is not something we want.
Please remove this event listener after the destroy() has been completed.
I cloned your demo and just manually set the width and height of the #canvasParent element. It seems to achieve the expected behavior.
Commit: c17e35
Preview: https://cycdpocodelab.github.io/jsmpeg-player-canvas/