Reputation: 39018
I've created a player for a client in the past using their LimeLight server to stream videos and not had an issue before, however for a new client using different LimeLight server, the videos seem to be ending 3-4 secs too early.
My traces on 3 vastly different videos I tested:
metadata duration = 32 // 32 secs long, ends at 27
Stop [27.350 seconds] = 4.65
metadata duration = 17 // 17 secs long, ends at 12
Stop [12.852 seconds] = 4.148
metadata duration = 258 // 258 secs long, ends at 255
Stop [255.861 seconds]
In the video players I check for NetStream.Play.Stop
then put a 'reset' type function in there. This function however triggers too early due to this strange bug. Has anyone have seen this before?
private function netStatusHandler(event:NetStatusEvent):void
{
trace("connected is: " + nc.connected );
switch (event.info.code)
{
case "NetConnection.Connect.Success":
trace("Connected");
connectStream();
break;
case "NetStream.Play.Start":
trace("********** Start [" + ns.time.toFixed(3) + " seconds]");
break;
case "NetStream.Play.Stop":
trace("‹ ----------- Playback has stopped. ----------- ›");
trace("Stop [" + ns.time.toFixed(3) + " seconds]");
if (nsBuffering){ removeChild(bufferAni); }
nsBuffering = false;
videoStatus = "NotPlaying";
resetVideo(); //<- Video ends so go back to start
// ^ This triggers too early
break;
}
}
The only work-around I see for this is saving the initial number I get from the metadata duration, and running a timer to constantly check for when the current ns.time matches metadata and then run my reset function.
Upvotes: 2
Views: 2917
Reputation: 31
I know this thread is incredibly old, but I was banging my head trying to resolve this issue; and aside from your solution, there just isn't much about it online.
So, I've figured it out. If you are using rtmp, you need to change bufferTime to false.
Since rtmp DOES NOT cache, there is no need for buffer time, and if you set one, you are limiting yourself and eventually the buffer will be empty.
ns.bufferTime = false;
Upvotes: 3
Reputation: 39018
http://www.wildform.com/support/tutorials/loopingFLVs/
I had to put in a check first when the netstream hit play.stop, then call my reset function when the buffer was empty...
The code on the site is AS2, but I converted it to AS3:
.
private function netStatusHandler(event:NetStatusEvent):void
{
trace("connected is: " + nc.connected );
switch (event.info.code)
{
case "NetConnection.Connect.Success":
trace("Connected");
connectStream();
break;
case "NetStream.Buffer.Empty":
trace("‹ ----------- Buffer is Empty! ----------- ›");
if (nsBuffering){ removeChild(bufferAni); }
nsBuffering = false;
if (videoFinished) // < Now I can run my reset
{
resetVideo();
videoFinished = false;
}
break;
case "NetStream.Buffer.Full":
trace("‹ ----------- Buffer is FULL! ----------- ›");
if (nsBuffering){ removeChild(bufferAni); }
nsBuffering = false;
break;
case "NetStream.Buffer.Flush":
trace("Data has finished streaming, remaining buffer will be emptied.");
videoStatus = "NotPlaying";
break;
case "NetStream.Play.Stop":
trace("‹ ----------- Playback has stopped. ----------- ›");
videoFinished = true; // < This first
break;
}
}
Upvotes: 7