-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Destroy Method #77
Comments
Yep should be straightforward. I'll take a look. Cheers 👍 |
Thanks for considering this! |
I was just about to request this. I'd like to point out that it's important to remove the media fully before destroying. I got around this by adding a removeMedia to my app's VideoPlayerView. I'll attach a little standalone jQuery snippet of it. var removeMedia = function () {
var $player = $('.player')[0];
$player.plyr.pause();
$player.plyr.media.src = '';
$('.player').find('source').prop('src', '');
//Now it's safe to unbind/undelegate all other events and destroy;
} I hadn't done an ajax video implementation in a while so I don't know what might be overkill or not. I always had memory leakage problems if I didn't remove the media before destroying the player element. |
Sorry for the delay, this is now in the latest version. I created https://github.com/Selz/plyr/blob/master/src/js/plyr.js#L1532 Remember if you're using AJAX, you can set the source using the |
I've downloaded the latest version but still not I'm not getting the destroy & restore functions "Uncaught TypeError: plyr.destroy is not a function" |
It's an API method so needs to be against an instance - check the docs |
We might want to use PLYR, but we're still facing problems with memory leaks. After calling the |
Another destroy method
|
I'm planning to use Plyr in an AJAX environment where pages are dynamically loaded. Currently there's no convenient way to destroy a Plyr instance to prevent memory leaks.
Is it possible to add a
.destroy()
method where all events are unbind, all markup removed, everything restored to the initial state.Thanks!
The text was updated successfully, but these errors were encountered: