调用NetStream.pause后,NetStream.Buffer.Full未被触发



我正在AS3中制作一个小型视频播放器,我发现在调用NetStream.pause()或NetStream.togglePause()后,不再发送状态消息。如果我在视频缓冲时点击"暂停"按钮,我永远不会得到缓冲。完整的消息。

下面是一些代码:
_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);
}

我错过了什么?

谢谢。

_connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
_connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);

时间晚了,却又遇到了同样的问题。当收到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;
  }

相关内容

  • 没有找到相关文章

最新更新