PDA

View Full Version : play 2 flvs through netstream


Billy T
12-17-2003, 03:36 AM
hey all

trying to play a couple of external flvs through 1 netstream object (ie one finishes, the next plays)

this works fine

// Create a NetConnection object:
var netConn2:NetConnection = new NetConnection();
// Create a local streaming connection:
netConn2.connect(null);
// Create a NetStream object and define an onStatus() function:
var netStream2:NetStream = new NetStream(netConn2);
netStream2.onStatus = function(infoObject) {
status2.text += "Status (NetStream2)" + newline;
status2.text += "Level: "+infoObject.level + newline;
status2.text += "Code: "+infoObject.code + newline;
if(infoObject.code=="NetStream.Play.Stop"){
trace('yep');
}
};
// Attach the NetStream video feed to the Video object:
my_video2.attachVideo(netStream2);
// Set the buffer time:
netStream2.setBufferTime(25);
// Being playing the FLV file:
netStream2.play("ed356k6.flv");

the trace happens and everybody is happy. But if I try to make it play the next vid with
if(infoObject.code=="NetStream.Play.Stop"){

netStream2.close();
my_video2.clear();
netStream2.play("ed156k.flv");
}


it continually crashes flash, crashes my browser etc...

what am I doing wrong?

Thanks

Billy T
12-17-2003, 03:43 AM
btw if I place a button comp on the stage and add this code

clippyListener = new Object();
clippyListener.click = function (evt){
netStream2.play("ed156k.flv");
}
but1.addEventListener("click", clippyListener)

and click this halfway through the first vid, it jumps to the second vid without any problems...

Mortimer Jazz
12-17-2003, 03:53 AM
Does it work if you do

if(infoObject.code=="NetStream.Play.Stop"){
netStream2.play("ed156k.flv");
}?

Billy T
12-17-2003, 03:55 AM
nope that was the first thing I tried

Mortimer Jazz
12-17-2003, 04:04 AM
I was thinking you may need to clear the video before you clear the stream but I guess not.
Maybe when the first stream finishes (without you interupting it) the object tries to re-initialise itself and there's a lag in doing so?

Try using a setInterval to repeatedly grab at the next video stream at second intervals

Billy T
12-17-2003, 04:19 AM
nice one mort

this

if (infoObject.code == "NetStream.Play.Stop") {
myInt=setInterval(loadNext,1000);
}


plus this


function loadNext() {
clearInterval(myInt);
netStream2.play("ed156k.flv");
}


work a treat...

Thanks mate!!

Mortimer Jazz
12-17-2003, 07:17 AM
:)

chrisgannon
05-14-2004, 09:44 AM
I tell you what - this thread/solution has saved my life/hair - I couldn't find anyone else with this problem and as usual MM are as useless as ever - cheers Mortimer and Billy T

Mortimer Jazz
05-14-2004, 12:01 PM
:]
For the benefit of anyone searching threads for netStream related stuff there is now a tutorial here
http://www.nwebb.co.uk/nw_htmlsite/index.php?page=browse_tutorial&tutorial=flv2&part=1
(soon to be on actionscript.org)

mpol777
05-14-2004, 01:23 PM
Just a note. As far as I have found it is not possible to play 2 stream simultaneously with the standard use of the netConnection/netStream Objects. I know this isn't what the BillyT was trying to do, but for people like me that are that search and find this thread... good luck. ;)

Mortimer Jazz
05-15-2004, 03:27 AM
Hi mpol - it is possible. Check out the analogy in my tutorial. I had two seperate streams running simultaneously when I was testing.

Cheers,
MJ