【发布时间】:2011-02-15 23:21:55
【问题描述】:
在 Flash 客户端,我如何检测服务器何时故意关闭与其视频流的 TCP 连接?发生这种情况时,我需要采取措施 - 可能会尝试重新启动视频或显示错误消息。目前,连接关闭和连接速度慢在我看来是一样的。在这两种情况下,NetStream 对象都会引发 NetStream.Play.Stop 事件。当连接速度较慢时,通常会在几秒钟内自行恢复。我希望只在连接关闭时采取行动,而不是在连接缓慢时采取行动。
这是我的一般设置的样子。这是基本的NetConnection->NetStream->Video 设置。
this.vidConnection = new NetConnection();
this.vidConnection.addEventListener(AsyncErrorEvent.ASYNC_ERROR, this.connectionAsyncError);
this.vidConnection.addEventListener(IOErrorEvent.IO_ERROR, this.connectionIoError);
this.vidConnection.addEventListener(NetStatusEvent.NET_STATUS, this.connectionNetStatus);
this.vidConnection.connect(null);
this.vidStream = new NetStream(this.vidConnection);
this.vidStream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, this.streamAsyncError);
this.vidStream.addEventListener(IOErrorEvent.IO_ERROR, this.streamIoError);
this.vidStream.addEventListener(NetStatusEvent.NET_STATUS, this.streamNetStatus);
this.vid.attachNetStream(this.vidStream);
当服务器关闭 TCP 或连接冻结时,不会触发任何错误事件。只有NetStream.Play.Stop 事件会触发。下面是从最初播放视频到 TCP 连接关闭的过程。
connection net status = NetConnection.Connect.Success
playStream(http://192.168.0.44/flv/4d29104a9aefa)
NetStream.Play.Start
NetStream.Buffer.Flush
NetStream.Buffer.Full
NetStream.Buffer.Empty
checkDimensions 0 0
onMetaData
NetStream.Buffer.Full
NetStream.Buffer.Flush
checkDimensions 960 544
NetStream.Buffer.Empty
NetStream.Buffer.Flush
NetStream.Play.Stop
当我在连接关闭和连接缓慢期间对各种属性进行转储时,我看不到可以帮助我区分关闭和缓慢的独特值。
NetConnection->connected = true
NetConnection->connectedProxyType = none
NetConnection->proxyType = none
NetConnection->uri = null
NetConnection->usingTLS = false
VidStream->bufferLength = 0
VidStream->bufferTime = 0.1
VidStream->bytesLoaded = 3204116
VidStream->bytesTotal = 3204116
VidStream->currentFPS = 0
VidStream->time = 63.797
【问题讨论】:
标签: flash actionscript-3 video tcp