Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a method to include logic in 'beforeunload' listener #76

Open
willnew opened this issue Nov 25, 2016 · 3 comments
Open

Adding a method to include logic in 'beforeunload' listener #76

willnew opened this issue Nov 25, 2016 · 3 comments

Comments

@willnew
Copy link

willnew commented Nov 25, 2016

I'm running a single page app on Electron using AngularJS, recently I find there are some memory issues on my app, here's what I did and see:

  1. Rendering a player in one view and play a video via rtsp stream

  2. Go to another view and do something

  3. Back to the first view, play another video

In this time the progressbar is jumping between the old video's time and the new one's. one thing to mention is that I was doing clearPlaylist before when leaving my page.

Then I digged into wcjs-player's index.js, and find that you wrote some code to clear related stuffs when page is reload, unfortunately that event is not triggered in single page app, so I added a testing function in wjs's prototype, which is a logic duplicate of the function called before page unload:

wcjs-destroy-func

It saved my day, could we add a function call rather than a listener in wcjs-player to support single page app?

@jaruba
Copy link
Owner

jaruba commented Nov 25, 2016

i think the memory consumption could of been solved just by using .stop() too

@jaruba
Copy link
Owner

jaruba commented Nov 25, 2016

what i don't like about this is that a true .destroy() function should also remove the entirety of the HTML code from the page too, not just unload the node modules and stop the player

@willnew
Copy link
Author

willnew commented Nov 27, 2016

@jaruba I got you. But I did use .clearPlaylist(), who called .stop() inside when leaving my view, but it doesn't help. I know the naming may not be appropriate, but what I want is to do the same thing when leaving my view like what you do in your listener who linsten to window's beforeunload event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants