How to remove / destroy a flowplayer instance?
Asked Answered
S

2

6

After create a flowplayer instance like this:

$f("player", "flowplayer.swf", "my-video.flv");

When remove the container element directly, $("#player").remove()(using jQuery),

I found the $f("player") still there. How to remove the instance really?

Semiconductor answered 25/4, 2012 at 8:24 Comment(0)
H
2

On BestKicker, we use $f().unload().

Hawsepiece answered 3/5, 2012 at 13:3 Comment(1)
if the container has no HTML content, $f.unload() does nothingSemiconductor
H
0

I basically stored the contents of the DOM element that holds the player element in jQuery data on DOM ready:

$('.video-holder').each(function(i,el){
    $(el).data('init-state', $(el).html());
});

... then reset the contents (thereby detaching the Flowplayer instance) by calling the stored data back into the holder element's HTML to effectively 'reset' it:

$('.video-holder').each(function(i,el){
    $(el).html($(el).data('init-state'));
});

I've only tried this using Flowplayer manual setup, don't think it'd work on auto. Also it probably wouldn't be great performance-wise if you were doing it over and over as the original Flowplayer instance is still loaded in memory, just detached, but was the best solution I could come up with.

Honkytonk answered 17/6, 2014 at 10:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.