我正在用AS3制作一个小视频播放器,我发现在调用NetStream.pause()或NetStream.togglePause()之后,没有任何状态消息被触发。如果我在视频缓冲时点击“暂停”按钮,我永远不会收到Buffer.Full消息。
下面是一些代码:
_connection = new NetConnection();
_connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
_connection.connect(null);
// create NetStream instance
_stream = new NetStream(_connection);
_stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
// event handler
// not called after the stream has been paused
private function netStatusHandler( e:NetStatusEvent ):void
{
trace("code:", e.info.code);
}
// pause button click handler
private function videoClickHandler( e:MouseEvent ):void
{
_stream.togglePause();
_isPaused = !_isPaused;
controls.playPause.gotoAndPlay((_isPaused) ? 10 : 3);
}这里我漏掉了什么?
谢谢。
发布于 2011-07-08 04:06:12
_connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
_connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);发布于 2015-10-31 03:25:10
几年太晚了,但遇到了同样的问题。我能够通过在接收NetStream.Unpause.Notify时查看bufferLength是否大于bufferTime来修复它。
如下所示的代码:
switch(event.info.code) {
case 'NetStream.Play.Start':
case 'NetStream.Buffer.Full':
currentState = 'playing';
return;
case 'NetStream.Unpause.Notify':
if (this.ns.bufferLength >= this.ns.bufferTime)
currentState = 'playing';
return;
case 'NetStream.Pause.Notify':
currentState = 'paused';
return;
}https://stackoverflow.com/questions/6603881
复制相似问题