I am currently working on a Flash webplayer with resolution switching functionality. I am trying to make use of the NetStream class's play2()
function in Actionscript.
The problem I am running into is that the videos don't change quickly. For those familiar with the play2()
function I believe that the player is performing a "standard switch"
rather than a "fast switch."
The documentation says that when the offset parameter is -1, fast switching occurs. What actually happens, though is once the "NetStream.Play.Transition"
event is received, the player waits until the time denoted by ns.time + ns.bufferLength
has been reached, before performing the switch.
I thought fast switching cleared the buffer, but on a check to ns.backbufferlength
, I found that everything is still cached. Also it mentions: "When offset is -1, the switch occurs at the first available keyframe after netstream.time + 3
," which is why I am confused.
Any help/insight on this matter would be much appreciated.
Here is a snippet of code describing what is going on (newStream()
is called when a user clicks to change to a new resolution, youtube style):
public function newStream(address:String):void
{
var opts:NetStreamPlayOptions = new NetStreamPlayOptions();
opts.streamName = address;
opts.transition = NetStreamPlayTransitions.SWITCH;
opts.offset = -1;
ns.play2(opts);
}
private function nsCallback(event:NetStatusEvent)
{
switch(event.info.code)
{
case "NetStream.Play.Transition":
{
trace("Current time (on Transition): " +
ns.time, "Buffer: " + ns.bufferLength);
var estTime:Number = ns.time + ns.bufferLength;
trace("Estimated Completion Time: " + estTime);
break;
}
}
}