How to close an AS3 FLV playback stream (properly)

This has been an issue for me and thousands of other Flash developers for, well, quite a few years – the problem happens when you want to stop an FLV from continuing to play by either stopping it and removing it from the stage like this:
flv.stop(); removeChild()

or setting

flv.source = null;

I used to have to check the stream for its state and do things based on that but now this just properly removes it. Well I hope this code might just be the final solution – it seems to also work well across the browsers I tested it with (Safari 4.0.5, Firefox 3.6.2, IE 8.0.6001).

The code is simple – make a reference to your FLVPlayback component, get the video player index (usually 0 if you’re not using multiple video player indexes) and then close it.

First remember to import the VideoPlayer class and any other classes you need.


var my_vp:VideoPlayer = my_flv.getVideoPlayer(0);

And that’s it! No more audio continuing playing after you allegedly unloaded a video or removed it.

And relax…

Hope that helps someone.


4 thoughts on “How to close an AS3 FLV playback stream (properly)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s