views:

485

answers:

6

Hi all,

I want to play an flv video file in my website. The video will be started playing considering the internet connection speed of client machine so that the video will never pause showing the loading image for buffering.

Either the buffering/streaming will be completed first then play or the video will start playing after a short delay while buffering will be done e.g. 40% and rest of buffering will go simultaneously so that the video will never pause and show the loading image.

How to accomplish this? Is it possible to implement?

Please help to implement this.

+1  A: 

The easiest way is to use Pre load asset manager. There is an example:

import gs.dataTransfer.PreloadAssetManager;
var preloader_obj = new PreloadAssetManager(["myFile1.swf","myFile2.swf"]);
this.onEnterFrame = function() {
    myPreloader_mc.bar_mc._xscale = preloader_obj.percentLoaded_num;
    if (preloader_obj.percentLoaded_num == 100) {
        gotoAndPlay("start");
    }
}

With percentLoaded_num you can set the amount that needs to be loaded before playing. Instead of the swf's use the flv's you want to preload. I haven't used it for flv's but it should work. Check the documentation for more information on this.

Also it's not a good idea to not allow buffering when not preloading the whole flv. Internet speeds are variable.

RonaldV
A: 

You can create custom buffering animations. If you don't want to show anything, I imagine you could create an animation that has nothing in it or that has no frames. See here for a video tutorial.

Mr. Shiny and New
A: 

you can use flex to add the video you want and customize your own video controller

like this

Sample Player with and without Video Controller

Hope this gives you an idea.

Treby
+1  A: 
Roger Pate
Nice tangent, but it really doesn't answer his question.
0A0D
It sounds like you're thinking of the "Eight Fallacies of Distributed Computing" by some guys from Sun... http://blogs.sun.com/jag/resource/Fallacies.html although you probably read the paper explaining them from http://www.rgoarchitects.com/Files/fallacies.pdf (Summary at wikipedia http://en.wikipedia.org/wiki/Fallacies_of_Distributed_Computing )
Stobor
Thank you! [15chars]
Roger Pate
A: 

Try this. Get the video duration and set that to your buffer time:

var netConn:NetConnection = new NetConnection();

// Create a local streaming connection
netConn.connect(null);
// Create a NetStream object and define an onStatus() function
var netStream:NetStream = new NetStream(netConn);
netStream.onStatus = function(infoObject) {
   status_txt.text += "Status (NetStream)" + newline;
   status_txt.text += "Level: "+infoObject.level + newline;
   status_txt.text += "Code: "+infoObject.code + newline;
};
// Attach the NetStream video feed to the Video object
my_video.attachVideo(netStream);
my_video.onMetaData = function(videoMetaData:Object):Void {   
   var videoDuration = videoMetaData.duration;
}
// Set the buffer time
netStream.setBufferTime(videoDuration);
// Begin playing the FLV file
netStream.play("http://www.mydomain.com/myvid.flv");
0A0D
+2  A: 

One thing that can really help you out is to encode the video at different bitrates. There's no getting around the fact that some people will simply have insufficient bandwidth to have consistently good video playback. Fortunately, Flash allows you to do dynamic stream switching based on the detected client bandwidth. To utilize this feature, rather than playing an FLV directly, you give the player a SMIL file playlist with the different streams listed. FLVPlayback has this functionality built in. Here's a sample SMIL file, stolen from here:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE smil PUBLIC "-//W3C//DTD SMIL 2.0//EN"
    "http://www.w3.org/2001/SMIL20/SMIL20.dtd"&gt;
<smil xmlns="http://www.w3.org/2001/SMIL20/Language"&gt;
    <body>
        <switch>
            <video src="video2.flv" system-bitrate="512000" />
            <video src="video1.flv" system-bitrate="256000" />
            <video src="video0.flv" />
        </switch>
    </body>
</smil>
Jacob