7 Replies Latest reply on Jul 5, 2013 6:33 AM by kglad

    Help With Volume Control For Video Player

    MissSmileyGirl

      Hey!

       

       

      My video plays and pauses just fine on my video player but I am having trouble figuring out this volume control. My slider moves the way I want it to but the volume does not adjust. Please tell me what is wrong with my code:

       

       

      slider_1.onPress = function() {

                this.startDrag(true, _root.volume_bar1._x, _root.volume_bar1._y, _root.volume_bar1._x + 133, _root.volume_bar1._y);

       

      }

      slider_1.onRelease = function() {

                this.stopDrag();

      }

       

      slider_1.onMouseMove = function() {

                newPoint = new Object();

                newPoint = this._x

                newPoint = this._y

                _root.volume_bar1.globalToLocal(newPoint);

                _root.demo_reel.setVolume(-1*newPoint.x);

      }

       

       

      I watched a tutorial and went off that code but of course with my own instance names.

       

      Thanks in advance!!

        • 1. Re: Help With Volume Control For Video Player
          kglad Adobe Community Professional & MVP

          if _root.demo_reel is an flvplayback component, use:

           

           

           

           

           

           

           

          paramsF(slider_1, _root.volume_bar1._x,0,_root.volume_bar1._x + 133,100);

           

          slider_1.onPress = function() {

                    this.startDrag(true, _root.volume_bar1._x, _root.volume_bar1._y, _root.volume_bar1._x + 133, _root.volume_bar1._y);

           

          }

          slider_1.onRelease = function() {

                    this.stopDrag();

          }

           

          slider_1.onMouseMove = function() {

          _root.demo_reel.volume = this.m*_rootvolume_bar1._x+this.b

          }

           

           

          function paramsF(mc:MovieClip,x1:Number,y1:Number,x2:Number,y2:Number):Void{
          mc.m=(y1-y2)/(x1-x1);
          mc.b=y1-mc.m*x1;
          }

           

          • 2. Re: Help With Volume Control For Video Player
            MissSmileyGirl Level 1

            That didn't work either. Thanks though

            • 3. Re: Help With Volume Control For Video Player
              kglad Adobe Community Professional & MVP

              use:

               

              paramsF(slider_1, _root.volume_bar1._x,0,_root.volume_bar1._x + 133,100);

               

              slider_1.onPress = function() {

              this.startDrag(true, _root.volume_bar1._x, _root.volume_bar1._y, _root.volume_bar1._x + 133, _root.volume_bar1._y);

              }

              slider_1.onRelease = function() {

              this.stopDrag();

              }

              slider_1.onMouseMove = function() {

              _root.demo_reel.volume = this.m*this._x+this.b;

              }

              function paramsF(mc:MovieClip,x1:Number,y1:Number,x2:Number,y2:Number):Void{

              mc.m=(y1-y2)/(x1-x1);

              mc.b=y1-mc.m*x1;

              }

              • 4. Re: Help With Volume Control For Video Player
                MissSmileyGirl Level 1

                Still not working.

                 

                I decided to start over using AS3 instead of AS2. Probably wasn't a good idea.

                 

                In AS3, I input the script but the play and pause buttons stop working and the volume slider doesn't slide. Without the script the play and pause buttons do work. The video automatically plays once I test the video. I don't want it to do that.

                 

                Here's my entire script:

                 

                /* Click To Play Video (Requires FLVPlayback component)

                Clicking on the symbol instance plays a video in the  specified FLVPlayback component instance.

                 

                 

                Instructions:

                1. Replace video_instance_name below with the instance name of the FLVPlayback component that you want to play the video.

                   The specified instance of FLVPlayback video component on stage will play.

                2. Make sure you have assigned a video source file in the properties of the FLVPlayback component instance.

                */

                 

                 

                play_btn.addEventListener(MouseEvent.CLICK, fl_ClickToPlayVideo);

                 

                 

                function fl_ClickToPlayVideo(event:MouseEvent):void

                {

                          // Replace video_instance_name with the instance name of the video component

                          reel_demo.play();

                }

                 

                 

                /* Click To Pause Video (Requires FLVPlayback component)

                Clicking on the symbol instance pauses the video in the specified FLVPlayback component instance.

                 

                 

                Instructions:

                1. Replace video_instance_name below with the instance name of the FLVPlayback component that you want to pause.

                */

                 

                 

                btn_pause.addEventListener(MouseEvent.CLICK, fl_ClickToPauseVideo);

                 

                 

                function fl_ClickToPauseVideo(event:MouseEvent):void

                {

                          // Replace video_instance_name with the instance name of the video component

                          reel_demo.stop();

                }

                 

                 

                // Volume Control starts here

                 

                 

                volume_slider.onPress = function() {

                          this.startDrag(true, _root.volume_bar._x, _root.volume_bar._y, _root.volume_bar._x + 108, _root.volume_bar._y);

                 

                 

                }

                 

                Even with just those two lines for the volume slider, the slider does not drag back and forth and the play and pause buttons do not work. What's the problem? Is it because it's AS3?

                • 5. Re: Help With Volume Control For Video Player
                  kglad Adobe Community Professional & MVP

                  when you drag your slider from one extreme to the other, what's the trace output from the following?  (ie, copy and paste the output):

                   

                  paramsF(slider_1, _root.volume_bar1._x,0,_root.volume_bar1._x + 133,100);

                   

                  slider_1.onPress = function() {

                  this.startDrag(true, _root.volume_bar1._x, _root.volume_bar1._y, _root.volume_bar1._x + 133, _root.volume_bar1._y);

                  }

                  slider_1.onRelease = function() {

                  this.stopDrag();

                  }

                  slider_1.onMouseMove = function() {

                  _root.demo_reel.volume = this.m*this._x+this.b;

                  trace(this.m+this._x+this.b);

                  }

                  function paramsF(mc:MovieClip,x1:Number,y1:Number,x2:Number,y2:Number):Void{

                  mc.m=(y1-y2)/(x1-x1);

                  mc.b=y1-mc.m*x1;

                  }

                  1 person found this helpful
                  • 6. Re: Help With Volume Control For Video Player
                    MissSmileyGirl Level 1

                    Sorry, I don't understand what you mean by trace output! I can't get the slider to drag at all!

                    • 7. Re: Help With Volume Control For Video Player
                      kglad Adobe Community Professional & MVP

                      if you can't get the slider to drag why have you been saying the code i suggested doesn't work??