gpt4 book ai didi

flash - 有人遇到这个错误吗? RTMP 流媒体视频提前 3-4 秒结束?

转载 作者:行者123 更新时间:2023-12-02 06:25:06 25 4
gpt4 key购买 nike

我过去曾为使用他们的 LimeLight 服务器流式传输视频的客户创建了一个播放器,之前没有遇到过问题,但是对于使用不同 LimeLight 服务器的新客户,视频似乎也以 3-4 秒结束早。

我在 3 个截然不同的视频上测试过的痕迹:

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]

在视频播放器中,我检查了 NetStream.Play.Stop,然后在其中放置了一个“重置”类型的函数。然而,由于这个奇怪的错误,这个函数触发得太早了。 有没有人以前见过这个?


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

我看到的唯一解决方法是保存我从元数据持续时间获得的初始数字,并运行一个计时器来不断检查当前 ns.time 何时匹配元数据,然后运行我的重置函数。

最佳答案

我找到了解决方案!

http://www.wildform.com/support/tutorials/loopingFLVs/

我必须先在网络流命中 play.stop 时进行检查,然后在缓冲区为空时调用我的重置函数...

网站上的代码是AS2,但我把它转换成了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;
}
}

关于flash - 有人遇到这个错误吗? RTMP 流媒体视频提前 3-4 秒结束?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2134450/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com