Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Dynamic Buffering

Guest
Nov 16, 2008 Nov 16, 2008
I'm tring to implement a dual buffering strategy. (Flash Media Server 3, Flash Player 9 and Actionscript 3)

I have a simple player with FLVComponent, a standard skin using the vod application.

I put in the first frame the following code:

videoPlayer.bufferTime = 8;
videoPlayer.source = root.loaderInfo.parameters.url; (I use the variable url to pass the video name)

I read your article but I don't know how to use the code. I tried to copy and past below my to lines and didn't work.

Please help me.

Thanks,
Thiago Prado

function initConnection() {
// Create a NetConnection
nc = new NetConnection();
// Define onStatus event handler
nc.onStatus = function(info) {
trace("Level: "+info.level+" Code: "+info.code);
// Initialize the stream after the connection is successful
if (info.code == "NetConnection.Connect.Success") {
trace("--- connected to: " + this.uri);
startStream(); //Inizialize the stream
}
};
// try to connect, to be changed with your app path
nc.connect("rtmp://localhost/vod");
}

function startStream() {
//Define stream and buffers parameters
stream_name="test_stream"; //your stream - How can I pass my variable url to stream_name?
startBufferLength=2; //keep this in the range 2-4+
expandedBufferLength=15; //arbitrarily high

// create a netstream
ns = new NetStream(nc);

// Define onStatus event handler
ns.onStatus = function(infoObject:Object) {
if (infoObject["code"]=="NetStream.Buffer.Full"){
ns.setBufferTime(expandedBufferLength);
trace("set expanded buffer");
}
if (infoObject["code"]=="NetStream.Buffer.Empty"){
ns.setBufferTime(startBufferLength);
trace("set start buffer");
}
}

// attach the NetStream to a video object
// change from videoObj to your istance name if needed
videoObj.attachVideo(ns);
ns.setBufferTime(startBufferLength);
ns.play(stream_name, 0);
}
initConnection();
stop();
TOPICS
ActionScript
568
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 16, 2008 Nov 16, 2008
Are you using FLVPlayback component or you intention is to write your own playback routine?

Your code suggests you are not using components.

Also, it looks like the code example you used is AS2 - not AS3. NetStream and NetConnection are handled a bit differently in AS3.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 16, 2008 Nov 16, 2008
Yes, I'm using the FLVPlayback component.
I thought the problem could be the diference between AS2 and AS3.
I have no idea how to change this code to AS3.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 16, 2008 Nov 16, 2008
LATEST
I don't use FLVPlayback (I write my own players) but for sure AS2 or AS3 the code you are trying to use is not good because it doesn't use FLVPlayback.

There is an example in CS3/CS4 of using FLVPlayback.

Here is documentation for the componenet:

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/video/FLVPlayback.html
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines