簡體   English   中英

調用 NetStream.pause 后未觸發 NetStream.Buffer.Full

[英]NetStream.Buffer.Full not fired after call to NetStream.pause

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

我在這里想念什么?

謝謝。

幾年太晚了,但遇到了同樣的問題。 我可以通過查看接收 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;
  }
_connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
_connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM