FLVPlayback - how to stream

Using Flash Pro 8 we have a web page that is utilizing flash.  On this flash file we are playing a FLV movie and we are using the FLVPlayback to run it.  We are not using a flash media server but rather a shared web hosting server.  The problem we have is viewers are complaining that the video is "choppy" which means it will start and stop often.  How do we prevent this?  Do we use a preloader?  If so, how do we do it?

Thanks in advance.
rudyflyerAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Aneesh ChopraConnect With a Mentor Commented:
yes, you can do it...

just create a movieClip with instancename "loading_mc"..
put a textField init or any loading animation as you want...

just place it over the FLVPlayBack component instance..

and put the following code on frame where FLVPlayBack component placed..
I assume that FLVPlayBack component instance name is "myFLV":
------------
var cuePt0 = new Object();
cuePt0.time = 1;
cuePt0.name = "started";
cuePt0.type = "actionscript";
myFLV.addASCuePoint(cuePt0);
//
var listenerObject = new Object();
listenerObject.cuePoint = function(eventObject)
{
     if (eventObject.info.name == "started")
     {
          loading_mc._visible = false;
     }
};
myFLV.addEventListener("cuePoint",listenerObject);
------------

Rgds
Aneesh
0
 
ZefferCommented:
check this out see if it solves things..failing that try this from macromedia forum>>

No screen name said on Mar 9, 2005 at 12:39 AM :

Hi ppl!
You've asked a real world examples?
I've made some kind of streaming preloader works similar to MS Windows media player.
You need three things in order to run it:
1. Create blank new flash file. Open library, add "New video" object to library, then add it to stage with the instance name "my_video".
2. Create new layer with a multy-line input text field w/ a border that lies above the "blank video object". The instance name of the txt object must be: "status_txt"
3. Add script written below to the first frame of the flash movie. Save flash movie with the name you want + put following FLV file (videoFile.flv) in the same directory where you're going to execute SWF for streaming.
//++++++++++++++++++++++ code begins: ++++++++++++++++++
status_txt.text += "initialize streaming engine" + newline;
// Create a NetConnection object
var netConn:NetConnection = new NetConnection();
status_txt.text += "creating net connection object..." + newline;
// Create a local streaming connection
netConn.connect(null);
var netStreamStatus = "";
var videoStatus = "loading";
// Create a NetStream object and define an onStatus() function
var netStream:NetStream = new NetStream(netConn);
//status_txt.text += "creating net stream object..." + newline;
netStream.onStatus = function(infoObject) {
//var lvl = infoObject.level;
//var code = infoObject.code;
//if (infoObject.code == "NetStream.Buffer.Full") {
//status_txt.text += newline + "Status (NetStream)" + newline;
//} else {
//status_txt.text += "Status (NetStream)" + newline;
//}
//status_txt.text += "Level: " + lvl + newline;
//status_txt.text += "Code: " + code + newline;
netStreamStatus = infoObject.code;
};
// Attach the NetStream video feed to the Video object
my_video.attachVideo(netStream);
//status_txt.text += "attach net streaming video" + newline;
// Set the buffer time
netStream.setBufferTime(10);
//status_txt.text += "set buffer time" + newline;
// Begin playing the FLV file
netStream.play("videoFile.flv");
//status_txt.text += "start streaming play" + newline;
this.onEnterFrame = function() {
if (netStreamStatus == "NetStream.Play.Start") {
var pos = status_txt.text.indexOf("buffering: ");
if(pos>-1) {
status_txt.replaceText(pos, status_txt.length, "buffering: " + netStream.bytesLoaded + " bytes loaded");
videoStatus = "buffering";
} else {
status_txt.text += "buffering: " + netStream.bytesLoaded + " bytes loaded "+ newline;
videoStatus = "buffering";
}
} else if (netStreamStatus == "NetStream.Buffer.Full") {
if(videoStatus == "buffering") {
status_txt.text += newline + "buffer loaded..." + newline + "playing movie" + newline;
videoStatus = "playing";
//status_txt.text += "video stat: " + videoStatus + newline;
}
} else if (netStreamStatus == "NetStream.Play.Stop") {
if(videoStatus == "playing") {
status_txt.text += "movie stopped" + newline;
videoStatus = "stopped";
//status_txt.text += "video stat: " + videoStatus + newline;
}
} else if (netStreamStatus == "NetStream.Buffer.Empty") {
if(videoStatus == "stopped") {
status_txt.text += "buffer empty..." + newline;
videoStatus = "empty";
//status_txt.text += "video stat: " + videoStatus + newline;
}
}
}
//++++++++++++++++++++++ code ends: ++++++++++++++++++
P.S.: If you did everything right, you'll see it works when you test it on remote server (don't test it locally).
For any questions, write me: igor@mixtv.tv

Z
0
 
rudyflyerAuthor Commented:
Zeffer,

I think I followed your directions but I don't think it is working properly.  For example, the text field always says "initialize streaming" and the video is still choppy.  I am a beginner at this so it is possible I am messing up something.  Do you think you could walk me through this?

Thanks.
0
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

 
Aneesh ChopraCommented:
Hi,

FLVPlayback component has a property BufferTime,
you can set BufferTime to 5 seconds, if you want that video of 5 seconds must load before start playing...

similarly, if you want that complete video should buffer before start playing, you can increase buffer time, it will work as preloader.

It on you how much video do you want to preload before start playing...

Rgds
Aneesh
0
 
rudyflyerAuthor Commented:
Aneesh,

Where do I set the Buffer Time?
0
 
Aneesh ChopraCommented:
Click the FLVPlayBack component instance and see the parameters tab below..
0
 
rudyflyerAuthor Commented:
Found it.  I set it to 20 seconds and it seems to work nicely now.  There is no more "choppy" movement.  Now the movie has about 5-8 seconds of a blank screen before the movie plays.  Is there a way I could put text in there that says "Loading"?
0
 
rudyflyerAuthor Commented:
Is this new movieclip a new layer in flash or do I put it on the same layer as the video?
0
 
Aneesh ChopraCommented:
To keep it clear, put it in a new layer just above the FLVPlayBack instnace layer
0
 
rudyflyerAuthor Commented:
When I publish I get this error:

**Error** Scene=Scene 1, layer=video, frame=1:Line 16: Statement must appear within on/onClipEvent handler
     var cuePt0 = new Object();

**Error** Scene=Scene 1, layer=video, frame=1:Line 17: Statement must appear within on/onClipEvent handler
     cuePt0.time = 1;

**Error** Scene=Scene 1, layer=video, frame=1:Line 18: Statement must appear within on/onClipEvent handler
     cuePt0.name = "started";

**Error** Scene=Scene 1, layer=video, frame=1:Line 19: Statement must appear within on/onClipEvent handler
     cuePt0.type = "actionscript";

**Error** Scene=Scene 1, layer=video, frame=1:Line 20: Statement must appear within on/onClipEvent handler
     myFLV.addASCuePoint(cuePt0);

**Error** Scene=Scene 1, layer=video, frame=1:Line 22: Statement must appear within on/onClipEvent handler
     var listenerObject = new Object();

**Error** Scene=Scene 1, layer=video, frame=1:Line 23: Statement must appear within on/onClipEvent handler
     listenerObject.cuePoint = function(eventObject)

**Error** Scene=Scene 1, layer=video, frame=1:Line 30: Statement must appear within on/onClipEvent handler
     myFLV.addEventListener("cuePoint",listenerObject);

Total ActionScript Errors: 8        Reported Errors: 8
0
 
rudyflyerAuthor Commented:
ignore last error I got....I fixed it.
0
 
rudyflyerAuthor Commented:
aneeshchopra,

Our video is about 2 minutes long.  We have BufferTime now set to 30.  At the start of the video everything loads fine.  But in the middle of the video and everything after it gets choppy again.  Do I need to set the BufferTime higher?
0
 
Aneesh ChopraCommented:
yes,
you have to decide on it

actually, it depends on connection speed,
you can increase the bufferTime to 60 seconds, it will start video when 60 seconds of video gets preloaded
and while playing one minutes of video, in background it will be loading the rest of the remaining video....

but still there are chances that a user with slower connection gets a choppy stoppage in the last of vidoe due to incomplete loading...

to avoid it completely, you can set the bufferTime to 100 seconds or more...

Rgds
Aneesh
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.