-
How to Close FLV player when stream ends
Hey peeps
Bit struggling with this problem for a while and google isn't helping me.
I need to have a flv player pop open when a button is clicked on a html page and when the flv video gets to the end the player disappears.
What i envisage happening is:
Button clicked, loads swf into empty <div> and chosen flv plays, in the script (AS3) i possibly have a listener that detects when stream has ended and closes the swf (popup).
the only thing is i have no idea what the AS would be for this, any one got any tips/advice??
This is the effect i am after http://www.net-a-porter.com/product/77770 (the video link)
thanks in advance
-
Total Universe Mod
When the watch button is clicked, it calles a javascript function which in turn populates a predefined div id with an .swf (probably using swfobject or something) which probably accepts a video id or filename via flashvars which is uses to populate its netstream object which streams to its video object. The playback completion listener (see below) then likely cleans up memory and communicates with javascript via externalinterface to replace the .swf with the previous contents.
The javascript used is readily available on the link you posted although it may take some digging.
The as3 listening would work as follows.
Actionscript Code:
import flash.media.Video; import flash.net.NetConnection; import flash.net.NetStream;
// a video object is just a screen for displaying movie data, its otherwise dumb // a netstream object actually connects to the .flv and sends its data to the video var video:Video = new Video();
// a netconnection is essentially a "pipe" through which data is sent var connection:NetConnection = new NetConnection(); connection.connect(null);
// a netstream basically controls the stopping, starting etc. of data through the pipe. var netstream:NetStream = new NetStream(connection); // we listen to the netstream for an event called NetStatus which has a property // called .info which contains a description of what actually just happened. netstream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
function netStatusHandler(event:NetStatusEvent):void{ //here we examine the info object to see if the status is the one we're looking for // in this case, it's "NetStream.Play.Stop" if(event.info.code == "NetStream.Play.Stop"){ //clean up code and external interface call would go here }
}
// finally we tie the netstream object to the video object so that you can actually see // the video and then point netstream to an .flv video.attachNetStream(stream); stream.play("myVideo.flv"); addChild(video);
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|