FORUMS: list search recent posts

Netstream buffer problem or ?

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
cow
Cornelius Matteo
Netstream buffer problem or ?
on Jun 5, 2006 at 8:52:14 pm

Hello All,

I am very new and this is code I am using to show multiple flv video in sucession. The .flv files are stored in same sub directory as swf file. Only problem is that after the 5th flv video file is displayed and cut short, the code starts showing flv videos from beginning rather than continuing on to show others. Any suggestions for what is going on here?
Thanks
C


var nc:NetConnection = new NetConnection();
nc.connect(null);

var ns:NetStream = new NetStream(nc);
var timer:Number = 1;

function playVideo(){
ns.play(randomVideoID());
}

function randomVideoID():String{
var randomNo:Number = timer++;

var randomMovie:String = "testimonial"+randomNo+".flv";
//trace(randomMovie);
return randomMovie;
}
ns.onStatus = function(info){

//trace("info code = ");
//trace(info.code);

if(info.code == "NetStream.Play.Stop"){
playVideo();
}
}

videoObj.attachVideo(ns);
playVideo();


Return to posts index

lajoiet
Re: Netstream buffer problem or ?
on Jun 6, 2006 at 1:24:41 am

Well, your random code doesn't seem to be doing anything random, it's just incrementing, and I don't see any code to check to see if it reaches a maximum number to get reset to start over again, so the behavior that you mention sounds very unusual. It also looks like you're jumping through hoops getting the actual file name into the ns.play comand.

Considering that you know the names of the FLVs, but I have no idea how many you have, if you truely want them to play randomly this is how I would do it (I'm going to assume for the sake of this code that you have 7 testimonial flvss)

var nc:NetConnection = new NetConnection();
nc.connect(null);

var ns:NetStream = new NetStream(nc);
var randNum:Number = ((Math.ceil(Math.random()) * 7);

function playVideo(){
switch (randNumb)
case 1:
ns.play(tetimonial1.flv);
break;
case 2:
ns.play(tetimonial2.flv);
break;
case 3:
ns.play(tetimonial3.flv);
break;
case 4:
ns.play(tetimonial4.flv);
break;
case 5:
ns.play(tetimonial5.flv);
break;
case 6:
ns.play(tetimonial6.flv);
break;
case 7:
ns.play(tetimonial7.flv);
break;
}

ns.onStatus = function(info){

//trace("info code = ");
//trace(info.code);

if(info.code == "NetStream.Play.Stop"){
playVideo();
}
}

videoObj.attachVideo(ns);
playVideo();

>Todd
_____________________________________

I'm filling a need. Without me there would be no bad examples.
_____________________________________


Return to posts index

Cornelius Matteo
Re: Netstream buffer problem or ?
on Jun 6, 2006 at 5:21:24 pm

Hi Todd,

Thanks for your reply. I could not get it to work (even correcting the typos (i.e. testimonial) but it was a good example for me to learn from. As I said, I am very new to Flash.

It shows an empty screen when I play your code.


Question: how in a loop that is showing one video after another, can I just end the Flash program? As in I get to the end of the 7 videos I want to show randomly.

Thx
C


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]