video.Maru
by polyGeek polyGeek logo



 

volume controls

June 24th, 2007 . by polyGeek
polyGeek TV Watch the video tutorial on how to create volume controls

The volume controls are comprised of the volumeRange, which can be oriented vertically or horizontally, and the volumeSlider.

The initial volume of the video will depend on the placement of the volumeSlider on the volumeRange. So if you want the volume to automatically be set at 50% then place the volumeSlider in the middle of the volumeRange.

The mute button is a toggle much like the play/pause button. To create a mute button place a MovieClip on the stage with an instance name of either soundon or soundoff. The instance name will determine the mute state when the SWF is loaded. So a mute button with an instance name of soundoff will cause the video to start with the sound off.

Inside of the mute button you can create two states indicated by Framelabels: on/off. When the volume is muted the video.Maru code will cause the mute button to gotoAndStop() on the off Framelabel and visa-vera.

Both volumeSlider and volumeRange support states depending on the state of the mute button - soundoff/soundon. If the volume is muted then, if supplied, the volumeRange/volumeSlider will gotoAndStop() on the muted frame label. When the sound is not muted then the volumeRange/volumeSlider will gotoAndStop() on the first frame of the MovieClip - no Framelabel is needed.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Technorati
  • del.icio.us
  • Facebook
  • Google
  • StumbleUpon

7 Responses to “volume controls”

  1. comment number 1 by: Matt

    I would like to know if I can add a volume control that when you are done adjusting the volume it will fade out just like the fadeTray.

    I just thought that would be a nice effect for my visitors.

  2. comment number 2 by: polyGeek

    @Matt, I’m I missing something? Couldn’t you just put the volume controls in the fadeTray?

    It would be fairly simple to write your own code so that when the user rolls over the volume controls they fade in and then fade out when the user rolls off again. I could do a tutorial on that if it would be helpful.

  3. comment number 3 by: Dexter

    Is there a way to mute the sound of a movie through the xml file?

  4. comment number 4 by: Noob

    This is an API
    Hope it helpes someone.
    I hope I didn’t reinvented the weel :P

    function SetClickableVolume(b:Boolean)
    {
    if( b )
    {
    volRange.onPress= function():Void {
    var perc:Number = (volRange._xmouse / volRange._width)*100;
    audio.setVolume( perc );
    music.setVolume( perc );

    if( isVolVert ) {
    volSlider._y = volRange._y + ( volRange._height * (perc/100) );
    } else {
    volSlider._x = volRange._x + ( volRange._width * (perc/100) );
    }
    }
    }
    }

  5. comment number 5 by: Andy

    I’m having a problem with the range/slider and the mute button. If I adjust the volume with the slider, and then click the mute button, the volume will mute but as soon as I move my mouse the volume comes back, yet the off state is still showing for the mute button.
    In other words, if I adjust the volume the mute button stops working.
    Any ideas?

  6. comment number 6 by: polyGeek

    @Andy, that sounds like an old bug. Do you have the latest version of videoMaru? ( Link in the top-right of each page. )

  7. comment number 7 by: Andy

    Ah, that’s my problem. Works great now.
    Thanks, man, I’m liking this.

Leave a Reply

Name

Mail (never published)

Website