0

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();
    _isPaused = !_isPaused;
    controls.playPause.gotoAndPlay((_isPaused) ? 10 : 3);
}

What am I missing here ?

Thanks.

dotminic
  • 1,135
  • 2
  • 14
  • 28
  • show how you created _connection – The_asMan Jul 07 '11 at 20:05
  • updated the code to show how I created the connection – dotminic Jul 07 '11 at 21:23
  • 1
    the code looks goo to me are you sure the connection to the server is being made. and the stream iws being sent from the server? Usually with streaming media you have to invoke server functions also. What streaming server are you using? – The_asMan Jul 07 '11 at 22:54
  • I also see no error handling functions like the one I posted in my answer. You might want top include those to see whats happening. – The_asMan Jul 07 '11 at 22:55
  • I'm just playing some basic f4v/flv files, I'm not using a streaming server, but any time it call NetStream.pause/togglePause no more status codes are "dispatched". I've sorted the problem using a timer and checking NetStream.bufferLength to see if the buffer is full. – dotminic Jul 08 '11 at 00:03

2 Answers2

0

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;
  }
jvogelsb
  • 1
  • 2
0
_connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
_connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
The_asMan
  • 6,364
  • 4
  • 23
  • 34