Solved

FLVPlayback - how to stream

Posted on 2006-06-29
13
8,014 Views
Last Modified: 2008-08-04
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.
0
Comment
Question by:rudyflyer
  • 7
  • 5
13 Comments
 
LVL 23

Expert Comment

by:Zeffer
ID: 17009023
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
 

Author Comment

by:rudyflyer
ID: 17009201
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
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 17009384
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
 

Author Comment

by:rudyflyer
ID: 17009457
Aneesh,

Where do I set the Buffer Time?
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 17009469
Click the FLVPlayBack component instance and see the parameters tab below..
0
 

Author Comment

by:rudyflyer
ID: 17009534
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 34

Accepted Solution

by:
Aneesh Chopra earned 500 total points
ID: 17010648
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
 

Author Comment

by:rudyflyer
ID: 17011110
Is this new movieclip a new layer in flash or do I put it on the same layer as the video?
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 17011134
To keep it clear, put it in a new layer just above the FLVPlayBack instnace layer
0
 

Author Comment

by:rudyflyer
ID: 17011255
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
 

Author Comment

by:rudyflyer
ID: 17011273
ignore last error I got....I fixed it.
0
 

Author Comment

by:rudyflyer
ID: 17012745
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
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 17015293
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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now