0

我在 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);
}

我在这里想念什么?

谢谢。

4

2 回答 2

0
_connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
_connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
于 2011-07-07T20:06:11.837 回答
0

几年太晚了,但遇到了同样的问题。我可以通过查看接收 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;
  }
于 2015-10-30T19:25:09.980 回答