player.destroy() would remove the iframe and everything the script created in Javascript that drains memory.
This method doesn't exist. player.unload() only resets the player to its initial state.
The Youtube API supports destroy() as described above.
I'm working on a one-pager website for a client where the user can swipe through projects and start videos inside them. When a project is entered the video is getting initialised. When they leave the project the video should get destroyed to free up memory.
+1
Would be good if this also removed the player container element from the internal map so that a new player instance can be added to the same container element.
@mmulvogue-work could you explain your use case a little more? Is there something that prevents you from using loadVideo() on an existing player?
Yeah sure - on a single page of our site authors can add multiple videos that can be sourced from either Vimeo or YouTube. The players are loaded in a single Bootstrap modal, thats setup specifically for embedding video players, with some script to dynamically load either the Vimeo/YT player inside a single container element and then destroy it when the modal is closed. At the moment this approach doesn't work if I try to re-use the same container element for Vimeo as once the element is in the map the API will no longer create a player, regardless of whether an actual player is present or not.
But you're right I could write some more code and hide the existing Vimeo player rather than destroy it, which no doubt would be faster, and then on each video load detect if there is an existing player and re-use rather than destroy it on close.
I guess am looking for an update to the api that makes the code for my particular solution simpler :)
I also have a situation that could use a .destroy() function. A website loads in content via ajax, sometimes with multiple Vimeo embeds. Each time the content is replaced, I'd like to remove any js that was related to the vimeo iframes bring removed.
+1
+1
+1
+1
+1
+1
+1
+1
This is basic basic stuff you guys
++
I waiting also on such method!
Thanks for your patience! https://github.com/vimeo/player.js/releases/tag/v2.5.0
Most helpful comment
+1
This is basic basic stuff you guys