Skip to main content
Participant
September 11, 2009
Question

SoundMixer.stopAll(); Affecting NetStream event.info.code - Bug?

  • September 11, 2009
  • 1 reply
  • 923 views

I'm loading and progressively streaming an F4V Video using pure actionscript code (No playback component used) and after the video begins streaming I place a MUTE button on the stage that when clicked executes the SoundMixer.stopAll(); instruction.

When the movie completes playing I use the following code to monitor the NetStream state changes and place a NEXT button on the stage when the video finishes.

When the video completes there is a NetStream event.info.code issued - "NetStream.Play.Stop"

This is detected by the following

switch (event.info.code) {
           

   case "NetConnection.Connect.Success":
                    connectStream();
                    break;
    case "NetStream.Play.StreamNotFound":
                    myTextBox1.text="Unable to locate video: " + videoURL;
                    break;
    case  "NetStream.Play.Stop":
                   trace ("Play stop mode reached");
                   showRedButton();
                   break;
    }

The problem is that when the SoundMixer.stopAll(); instruction is issued, Netstream no longer issues the "NetStream.Play.Stop" event state so my NEXT button (showRedButton(); instruction) fails to load if the user clicks the MUTE  button.

The only way I seem to be able to solve this is by adding the following code to my switch statement since NetStream is still issuing a Buffer.Flush message about 10 times as the video is ending. To prevent the NEXT Button from appearing too early I track the number of times the Buffer.Flush message is issued:

    case  "NetStream.Buffer.Flush":
     ++flushCount;
     if(flushCount>7 && buttonOn==0)
     {
     showRedButton();
     buttonOn=1;
     }
     break;

Has anyone else found this to be an issue or a known bug?

This topic has been closed for replies.

1 reply

Inspiring
September 11, 2009

Why don't you use NetStream soundTransform method instead? It is native to NetStream:

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/NetStream.html#soundTransform

xongooliAuthor
Participant
September 11, 2009

Thanks

The first time I tried SoundTransform it didn't work - then I found this more simplified code which works perfectly:

var myNetStream:NetStream = new NetStream();
var mySoundTransform:SoundTransform = new SoundTransform();

function btnVolume(e:Event):void{
mySoundTransform.volume = 0;
myNetStream.soundTransform = mySoundTransform;
}

to make the same function to do two things you can write a two-state switch:

function btnVolume(e:Event):void{
mySoundTransform.volume = 1 - mySoundTransform.volume;
myNetStream.soundTransform = mySoundTransform;
}

So, if the volume is 1 - it will become 0, if it is 0 - it will become 1.