2011-07-06 25 views
0

我在AS3中製作了一個小型視頻播放器,並且在調用NetStream.pause()或NetStream.togglePause()後發現,沒有狀態消息正在被解僱。 如果在視頻緩衝時單擊「暫停」按鈕,我永遠不會收到Buffer.Full消息。NetStream.Buffer.Full在調用NetStream.pause後未觸發

下面是一些代碼:

_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); 
} 

缺少什麼我在這裏?

謝謝。

+0

告訴你如何創建_connection –

+0

更新的代碼,以顯示我是如何創建的代碼看起來咕我的連接 – dotminic

+1

你確定到服務器的連接正在取得進展。流iws是從服務器發送的? 通常在流媒體中你也必須調用服務器功能。你使用什麼流媒體服務器? –

回答

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

多年已經太晚了,但遇到了同樣的問題。我能夠通過查看緩衝區長度是否大於接收NetStream.Unpause.Notify時的緩衝時間來修復它。

代碼與此類似:

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