7 Replies Latest reply: Aug 12, 2012 8:35 AM by MARKARKARK RSS

    Volume control

    MARKARKARK Community Member

      Hello,

      I have a flash game with several videos.  I am using netstream to play my videos.  the project is in actionscript 2.0.  Is there a way to adjust the volume of the videos individually?  Most of my videos have correct volume, but some are too quiet.

       

      Mark.

        • 1. Re: Volume control
          kglad MVP

          each netstream instance has a soundTransform property you can use.

          • 2. Re: Volume control
            MARKARKARK Community Member

            How do I do this, I don't see anything in the code to make this happen.

            • 3. Re: Volume control
              kglad MVP

              :

               

              var st:SoundTransform=your_ns.soundTransform;

              st.volume=.5;

              your_ns.soundTransform=st;

              • 4. Re: Volume control
                MARKARKARK Community Member

                Thank you for your help.  I have tried to put your script in what I have and I am doing something wrong.  I put the code in every spot that I thought would work and changed the "your.ns" to "new NetConnection()", "new NetStream(nc)" and "aud1."  None have worked.  Below is the code that plays my video and reacts to cue points. 

                 

                var nc:NetConnection = new NetConnection();

                nc.connect(null);

                var ns:NetStream = new NetStream(nc);

                aud1.attachVideo(ns);

                ns.play("http://www.mysite.org/video/myvideo/1.flv");

                ns.onCuePoint = function(evt:Object){

                    trace(evt.name);

                    trace(evt.time);

                    if(evt.name == "c1") {

                        trace("YO !Jump to 108!");

                        gotoAndPlay(108);

                    } 

                };

                 

                Thanks again for your help.

                 

                Mark.

                • 5. Re: Volume control
                  MARKARKARK Community Member

                  I had started another post, I appologize if this caused any inconvenience.  The last posting gave a solution, but it did not work.  the error message I get is,

                  Under Location:

                  Scene+Scene 1, layer=vid action, frame=114. line 4

                  Under Description:

                  The class or interface 'SoundTransform' could not be loaded.

                  Under Source

                  var st:SoundTransform=ns.soundTransform;

                   

                  The code I loaded in the actions frame:

                  var nc:NetConnection = new NetConnection();

                  nc.connect(null);

                  var ns:NetStream = new NetStream(nc);

                  var st:SoundTransform=ns.soundTransform;

                  st.volume=0.5;

                  ns.soundTransform=st;

                  aud1.attachVideo(ns);

                  ns.play("www.mysite.org/video/1.flv");

                  ns.onCuePoint = function(evt:Object){

                      trace(evt.name);

                      trace(evt.time);

                      if(evt.name == "c1") {

                          trace("YO !Jump to 108!");

                          gotoAndPlay(108);

                      }

                  };

                   

                  This was the suggestion of the last post.

                   

                  Thank you again for your help.

                   

                  Mark.

                  • 6. Re: Volume control
                    adninjastrator Community Member

                    I believe that soundTransform is AS3, while the rest of your project is AS2... so that won't work.

                    You can use this method instead:

                    //-------Sound Controls--------//
                    this.createEmptyMovieClip("sound_mc",this.getNextHighestDepth());
                    sound_mc.attachAudio(ns);

                    var videoSound:Sound = new Sound(sound_mc);
                    videoSound.setVolume(100);

                    Use volume of 100 as starting point. For turn up volume on very quiet videos, set volume to 400 or so. To turn volume down, use a volume less than 100.

                    Add this code in after the very last

                    };

                    of the code you posted... The audio control code does not go inside ns play function.

                    Best wishes,

                    Adninjastrator

                    • 7. Re: Volume control
                      MARKARKARK Community Member

                      Thank you so much, everytime you have responded to a problem, you have the correct answer.  Thank you, you are fantastic!

                      Mark.