开发者

NetStream.Buffer.Full not fired after call to NetStream.pause

I'm making a small video players in AS3, and I've found that after calling NetStream.pause() or NetStream.togglePause(), no status messages are being fired any more. If I click the "pause" button while the video is buffering, I never get the Buffer.Full message.

Here is some code:

_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();
  开发者_Go百科  _isPaused = !_isPaused;
    controls.playPause.gotoAndPlay((_isPaused) ? 10 : 3);
}

What am I missing here ?

Thanks.


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


Years too late, but ran into the same issue. I was able to fix it by looking to see if the bufferLength was greater than the bufferTime when receiving the NetStream.Unpause.Notify.

Code similar to this:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜