Solved

FLVPlayback - how to stream

Posted on 2006-06-29
13
8,020 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

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
 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SWF won't scale? 4 533
HTML 5 or Flash 7 493
Embedded Webpage Videos don't auto play on Windows 7 1 129
flash in chrome 4 140
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
Suggested Courses

739 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