17 Replies Latest reply: May 9, 2013 10:32 AM by kglad RSS

    Adjust volume on autoplay with a playlist xml ?

    Acidhunter Community Member

      Hello all,

      I have a problem i struggle with for some weeks now and i cant find the info i need about it.
      On my webpage i have a xml playlist who start to play songs automatic after load.
      My issue is that i cant change the volume of these in the player.

      What i want is to adjust the volume slider to play the songs with 50% volume for example and not 100% volume as they do now.

      Hope anyone can help me out with this as i not was able to find any info about to do this.

      Here are the code for my mp3 player:

       

      stop();
      var songs:Array = new Array();
      var curtrack:Number = 0;
      var playingsong:Sound = new Sound();

      loadSongs();
      loadplaylistbox();
      loadSong(curtrack);
      if (_root.autostart == "false") {
        toggleplaypause();
      }

      function loadSongs() {
      for (songIndex=0; songIndex<_root.playlistXml.childNodes[0].childNodes[0].childNodes.length; songIndex++) {
        var songdata:Object = new Object();
        for (songNode=0; songNode<_root.playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].childNodes.l ength; songNode++) {
         switch(_root.playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].childNodes[son gNode].nodeName){
         case "creator":
          songdata.artist = _root.playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].childNodes[songNode]. childNodes[0].nodeValue;
          break;
         case "title":
          songdata.title = _root.playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].childNodes[songNode]. childNodes[0].nodeValue;
          break;
         case "location":
          songdata.location = _root.playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].childNodes[songNode]. childNodes[0].nodeValue;
          break;
         }
        }
        songs[songIndex] = songdata;
      }
      }
      function loadSong(track) {
      playingsong = new Sound();
      playingsong.loadSound(songs[track].location, true);
      playingsong.start(0);
      updatevolume();
      playingsong.onSoundComplete = function() {
        loadSong((curtrack+1)%(songs.length));
      };
      playpause.gotoAndStop(1);
      playpause.playpausebutton.onPress = function() {
        toggleplaypause();
      };
      songdisplay.text = songs[track].artist+" - "+songs[track].title;
      eval("playlistbox.playlistitemcontainer.playlistitem"+curtrack+".playlistitemhighlight"). _alpha = 100;
      eval("playlistbox.playlistitemcontainer.playlistitem"+track+".playlistitemhighlight")._al pha = 1;
      curtrack = track;
      }
      function loadplaylistbox() {
      for (songIndex=0; songIndex<_root.playlistXml.childNodes[0].childNodes[0].childNodes.length; songIndex++) {
        playlistbox.playlistitemcontainer.attachMovie("playlistitem", "playlistitem"+songIndex, playlistbox.playlistitemcontainer.getNextHighestDepth(), {_x:0, _y:15*songIndex});
        eval("playlistbox.playlistitemcontainer.playlistitem"+songIndex+".playlistitemtext").text = songs[songIndex].artist+" - "+songs[songIndex].title;
        eval("playlistbox.playlistitemcontainer.playlistitem"+songIndex).songindex = songIndex;
      }
      }
      playpause.playpausebutton.onPress = function() {
      toggleplaypause();
      };
      function toggleplaypause() {
      if (playpause._currentframe == 1) {
        playpause.gotoAndStop(2);
        playpause.curpos = playingsong.position;
        playingsong.stop();
      } else {
        playpause.gotoAndStop(1);
        playingsong.start(playpause.curpos/1000, 0);
      }
      playpause.playpausebutton.onPress = function() {
        toggleplaypause();
      };
      }
      onEnterFrame = function () {
      if (songdisplay.movingright) {
        //songdisplay.hscroll -= 10;
        if (songdisplay.hscroll<=0) {
         //songdisplay.movingright = false;
        }
      } else {
        //songdisplay.hscroll += 10;
        if (songdisplay.hscroll>=songdisplay.maxhscroll) {
         //songdisplay.movingright = true;
        }
      }
      if (!draggingslider) {
        progressslider._x = (playingsong.position/playingsong.duration)*182-89;
        //if (progressslider._x == 0) {
         //progressslider._x = 61;
        //}
      }
      if (draggingplaylistscroller) {
        updateplaylistscroll();
      }
      if (draggingvolmeslider) {
        updatevolume();
      }
      tempsongtime = "";
      if (Math.floor(playingsong.position/60000) == 0) {
        tempsongtime += "0";
      } else {
        tempsongtime += Math.floor(playingsong.position/60000);
      }
      tempsongtime += ":";
      if (Math.floor((playingsong.position/1000)%60)<10) {
        tempsongtime += "0";
      }
      tempsongtime += Math.floor((playingsong.position/1000)%60);
      tempsongtime += "/";
      if (Math.floor(playingsong.duration/60000) == 0) {
        tempsongtime += "0";
      } else {
        tempsongtime += Math.floor(playingsong.duration/60000);
      }
      tempsongtime += ":";
      if (Math.floor((playingsong.duration/1000)%60)<10) {
        tempsongtime += "0";
      }
      tempsongtime += Math.floor((playingsong.duration/1000)%60);
      songtime.text = tempsongtime;

      };
      progressslider.onPress = function() {
      draggingslider = true;
      progressslider.startDrag(true, -89, progressslider._y, 93, progressslider._y);
      };
      progressslider.onRelease = progressslider.onReleaseOutside=function () {
      progressslider.stopDrag();
      playingsong.start(((progressslider._x+89)/182)*playingsong.duration/1000, 0);
      playpause.gotoAndStop(1);
      playpause.playpausebutton.onPress = function() {
        toggleplaypause();
      };
      draggingslider = false;
      };
      progressbar.onPress = function() {
      playingsong.start(((this._xmouse+2)/182)*playingsong.duration/1000, 0);
      playpause.gotoAndStop(1);
      playpause.playpausebutton.onPress = function() {
        toggleplaypause();
      };
      };
      volumebar.onPress = function() {
      draggingvolmeslider = true;
      volumebar.volumeslider.startDrag(true, 0, volumebar.volumeslider._y, 47, volumebar.volumeslider._y);
      };
      volumebar.onRelease = volumebar.onReleaseOutside=function () {
      draggingvolmeslider = false;
      volumebar.volumeslider.stopDrag();
      updatevolume();
      };
      function updatevolume() {
      playingsong.setVolume((volumebar.volumeslider._x/47)*100);
      }
      previoussong.onPress = function() {
      loadprevioussong();
      };
      function loadprevioussong() {
      var loadtrack = (curtrack-1)%(songs.length);
      if (loadtrack<0) {
        loadtrack = songs.length-1;
      }
      loadSong(loadtrack);
      }
      nextsong.onPress = function() {
      loadnextsong();
      };
      function loadnextsong() {
      var loadtrack = (curtrack+1)%(songs.length);
      loadSong(loadtrack);
      }
      playlistscroller.onPress = function() {
      draggingplaylistscroller = true;
      playlistscroller.startDrag(true, 452, -80, 452, -59);
      };
      playlistscroller.onRelease = playlistscroller.onReleaseOutside=function () {
      draggingplaylistscroller = false;
      playlistscroller.stopDrag();
      };
      playlistscrollup.onPress = function() {
      playlistscroller._y = Math.max(-80, playlistscroller._y-0.5);
      updateplaylistscroll();
      };
      playlistscrolldown.onPress = function() {
      playlistscroller._y = Math.min(-59, playlistscroller._y+0.5);
      updateplaylistscroll();
      };
      var mouseListener:Object = new Object();
      mouseListener.onMouseWheel = function(delta:Number) {
      playlistscroller._y = Math.min(-59, Math.max(-80, playlistscroller._y-delta));
      updateplaylistscroll();
      };
      Mouse.addListener(mouseListener);
      playlistscrollbar.onPress = function() {
      playlistscroller._y = Math.min(-59, Math.max(-80, _ymouse));
      updateplaylistscroll();
      };
      function updateplaylistscroll() {
      playlistbox.playlistitemcontainer._y = -((playlistscroller._y +80)/21)*(playlistbox.playlistitemcontainer._height-69);
      }

        • 1. Re: Adjust volume on autoplay with a playlist xml ?
          kglad CommunityMVP

          use playingsong.setVolume():

           

          playingsong.setVolume(50);  // 50%

          • 2. Re: Adjust volume on autoplay with a playlist xml ?
            Acidhunter Community Member

            Thank you very much kglad !
            Can you also help me to show where the code shall be placed ?
            I am not able yet to see where it shall be placed, except that its probably not in the top of the code.


            Can it be here ?

             

            loadSongs();
            loadplaylistbox();
            loadSong(curtrack);
            playingsong.setVolume(50);  // 50%

            if (_root.autostart == "false") {
              toggleplaypause();
            }

            • 3. Re: Adjust volume on autoplay with a playlist xml ?
              kglad CommunityMVP

              for loaded sounds, you should assign a volume after loading is complete.  you'll need to start a loop (eg, onEnterFrame) and check the getBytesLoaded() with getBytesTotal() to find when loading is complete.

               

              also, it looks like you're already adjust the volume using a slider (though that code may not be correct).

              • 4. Re: Adjust volume on autoplay with a playlist xml ?
                Acidhunter Community Member

                Hello kglad,

                 

                Thanks again for your reply.
                I cant find out the place to set in the code you wrote and neither to see where i already adjust the volume byt the
                volumeslider.
                Its confusing me more than i learn for a newbie like me, hehe
                Will it help if you get the fla. file to see all and show me ?
                If i can send it to you by Im i would apreciate that bec i am not sure i am allowed to send it public bec of rights.

                 

                thanks Again

                • 5. Re: Adjust volume on autoplay with a playlist xml ?
                  kglad CommunityMVP

                  when you adjust your volumne slider from one extreme to the other, what trace output do you see (copy/paste) using:

                  stop();
                  var songs:Array = new Array();
                  var curtrack:Number = 0;
                  var playingsong:Sound = new Sound();

                  loadSongs();
                  loadplaylistbox();
                  loadSong(curtrack);
                  if (_root.autostart == "false") {
                    toggleplaypause();
                  }

                  function loadSongs() {
                  for (songIndex=0; songIndex<_root.playlistXml.childNodes[0].childNodes[0].childNodes.le ngth; songIndex++) {
                    var songdata:Object = new Object();
                    for (songNode=0; songNode<_root.playlistXml.childNodes[0].childNodes[0].childNodes[son gIndex].childNodes.length; songNode++) {
                     switch(_root.playlistXml.childNodes[0].childNodes[0].childNodes[songI ndex].childNodes[songNode].nodeName){
                     case "creator":
                      songdata.artist = _root.playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].c hildNodes[songNode].childNodes[0].nodeValue;
                      break;
                     case "title":
                      songdata.title = _root.playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].c hildNodes[songNode].childNodes[0].nodeValue;
                      break;
                     case "location":
                      songdata.location = _root.playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].c hildNodes[songNode].childNodes[0].nodeValue;
                      break;
                     }
                    }
                    songs[songIndex] = songdata;
                  }
                  }
                  function loadSong(track) {
                  playingsong = new Sound();
                  playingsong.loadSound(songs[track].location, true);
                  playingsong.start(0);
                  updatevolume();
                  playingsong.onSoundComplete = function() {
                    loadSong((curtrack+1)%(songs.length));
                  };
                  playpause.gotoAndStop(1);
                  playpause.playpausebutton.onPress = function() {
                    toggleplaypause();
                  };
                  songdisplay.text = songs[track].artist+" - "+songs[track].title;
                  eval("playlistbox.playlistitemcontainer.playlistitem"+curtrack+".play listitemhighlight")._alpha = 100;
                  eval("playlistbox.playlistitemcontainer.playlistitem"+track+".playlis titemhighlight")._alpha = 1;
                  curtrack = track;
                  }
                  function loadplaylistbox() {
                  for (songIndex=0; songIndex<_root.playlistXml.childNodes[0].childNodes[0].childNodes.le ngth; songIndex++) {
                    playlistbox.playlistitemcontainer.attachMovie("playlistitem", "playlistitem"+songIndex, playlistbox.playlistitemcontainer.getNextHighestDepth(), {_x:0, _y:15*songIndex});
                    eval("playlistbox.playlistitemcontainer.playlistitem"+songIndex+".pla ylistitemtext").text = songs[songIndex].artist+" - "+songs[songIndex].title;
                    eval("playlistbox.playlistitemcontainer.playlistitem"+songIndex).song index = songIndex;
                  }
                  }
                  playpause.playpausebutton.onPress = function() {
                  toggleplaypause();
                  };
                  function toggleplaypause() {
                  if (playpause._currentframe == 1) {
                    playpause.gotoAndStop(2);
                    playpause.curpos = playingsong.position;
                    playingsong.stop();
                  } else {
                    playpause.gotoAndStop(1);
                    playingsong.start(playpause.curpos/1000, 0);
                  }
                  playpause.playpausebutton.onPress = function() {
                    toggleplaypause();
                  };
                  }
                  onEnterFrame = function () {
                  if (songdisplay.movingright) {
                    //songdisplay.hscroll -= 10;
                    if (songdisplay.hscroll<=0) {
                     //songdisplay.movingright = false;
                    }
                  } else {
                    //songdisplay.hscroll += 10;
                    if (songdisplay.hscroll>=songdisplay.maxhscroll) {
                     //songdisplay.movingright = true;
                    }
                  }
                  if (!draggingslider) {
                    progressslider._x = (playingsong.position/playingsong.duration)*182-89;
                    //if (progressslider._x == 0) {
                     //progressslider._x = 61;
                    //}
                  }
                  if (draggingplaylistscroller) {
                    updateplaylistscroll();
                  }
                  if (draggingvolmeslider) {
                    updatevolume();
                  }
                  tempsongtime = "";
                  if (Math.floor(playingsong.position/60000) == 0) {
                    tempsongtime += "0";
                  } else {
                    tempsongtime += Math.floor(playingsong.position/60000);
                  }
                  tempsongtime += ":";
                  if (Math.floor((playingsong.position/1000)%60)<10) {
                    tempsongtime += "0";
                  }
                  tempsongtime += Math.floor((playingsong.position/1000)%60);
                  tempsongtime += "/";
                  if (Math.floor(playingsong.duration/60000) == 0) {
                    tempsongtime += "0";
                  } else {
                    tempsongtime += Math.floor(playingsong.duration/60000);
                  }
                  tempsongtime += ":";
                  if (Math.floor((playingsong.duration/1000)%60)<10) {
                    tempsongtime += "0";
                  }
                  tempsongtime += Math.floor((playingsong.duration/1000)%60);
                  songtime.text = tempsongtime;

                  };
                  progressslider.onPress = function() {
                  draggingslider = true;
                  progressslider.startDrag(true, -89, progressslider._y, 93, progressslider._y);
                  };
                  progressslider.onRelease = progressslider.onReleaseOutside=function () {
                  progressslider.stopDrag();
                  playingsong.start(((progressslider._x+89)/182)*playingsong.duration/1 000, 0);
                  playpause.gotoAndStop(1);
                  playpause.playpausebutton.onPress = function() {
                    toggleplaypause();
                  };
                  draggingslider = false;
                  };
                  progressbar.onPress = function() {
                  playingsong.start(((this._xmouse+2)/182)*playingsong.duration/1000, 0);
                  playpause.gotoAndStop(1);
                  playpause.playpausebutton.onPress = function() {
                    toggleplaypause();
                  };
                  };
                  volumebar.onPress = function() {
                  draggingvolmeslider = true;
                  volumebar.volumeslider.startDrag(true, 0, volumebar.volumeslider._y, 47, volumebar.volumeslider._y);
                  };
                  volumebar.onRelease = volumebar.onReleaseOutside=function () {
                  draggingvolmeslider = false;
                  volumebar.volumeslider.stopDrag();
                  updatevolume();
                  };
                  function updatevolume() {

                  trace((volumebar.volumeslider._x / 47) * 100)

                  playingsong.setVolume((volumebar.volumeslider._x/47)*100);
                  }
                  previoussong.onPress = function() {
                  loadprevioussong();
                  };
                  function loadprevioussong() {
                  var loadtrack = (curtrack-1)%(songs.length);
                  if (loadtrack<0) {
                    loadtrack = songs.length-1;
                  }
                  loadSong(loadtrack);
                  }
                  nextsong.onPress = function() {
                  loadnextsong();
                  };
                  function loadnextsong() {
                  var loadtrack = (curtrack+1)%(songs.length);
                  loadSong(loadtrack);
                  }
                  playlistscroller.onPress = function() {
                  draggingplaylistscroller = true;
                  playlistscroller.startDrag(true, 452, -80, 452, -59);
                  };
                  playlistscroller.onRelease = playlistscroller.onReleaseOutside=function () {
                  draggingplaylistscroller = false;
                  playlistscroller.stopDrag();
                  };
                  playlistscrollup.onPress = function() {
                  playlistscroller._y = Math.max(-80, playlistscroller._y-0.5);
                  updateplaylistscroll();
                  };
                  playlistscrolldown.onPress = function() {
                  playlistscroller._y = Math.min(-59, playlistscroller._y+0.5);
                  updateplaylistscroll();
                  };
                  var mouseListener:Object = new Object();
                  mouseListener.onMouseWheel = function(delta:Number) {
                  playlistscroller._y = Math.min(-59, Math.max(-80, playlistscroller._y-delta));
                  updateplaylistscroll();
                  };
                  Mouse.addListener(mouseListener);
                  playlistscrollbar.onPress = function() {
                  playlistscroller._y = Math.min(-59, Math.max(-80, _ymouse));
                  updateplaylistscroll();
                  };
                  function updateplaylistscroll() {
                  playlistbox.playlistitemcontainer._y = -((playlistscroller._y +80)/21)*(playlistbox.playlistitemcontainer._height-69);
                  }

                  • 6. Re: Adjust volume on autoplay with a playlist xml ?
                    Acidhunter Community Member

                    When i use the volumeslider from one exstreme to another, i get these lines in output for the slider :

                     

                    100.531914893617
                    17.0212765957447
                    17.0212765957447
                    17.0212765957447
                    17.0212765957447
                    93.8297872340426
                    93.8297872340426
                    93.8297872340426
                    93.8297872340426

                    • 7. Re: Adjust volume on autoplay with a playlist xml ?
                      kglad CommunityMVP

                      when you move that slider (after your sound starts to play), does it change the sound's volume?

                      • 8. Re: Adjust volume on autoplay with a playlist xml ?
                        Acidhunter Community Member

                        yes it change the volume while i am playing.

                         

                        You can check it out here by yourself if you want.

                        aciex.dk/testfinal

                        • 9. Re: Adjust volume on autoplay with a playlist xml ?
                          kglad CommunityMVP

                          ok, so what is that you want to change?

                          • 10. Re: Adjust volume on autoplay with a playlist xml ?
                            Acidhunter Community Member

                            i want to change the volume of the tracks  who automatic are playing when you enter the site !

                            Right now it play with 100% volume by default and its too loud.

                            I would like the slider to start play with 50%  of the volume or something like that.

                            • 11. Re: Adjust volume on autoplay with a playlist xml ?
                              kglad CommunityMVP

                              use the slider and the code below to get a volume of about 50% and note the volumeslider's _x value:

                               

                              you can then assign that value at the start of your app and call updatevolume() after your first sound loads.

                               

                              stop();
                              var songs:Array = new Array();
                              var curtrack:Number = 0;
                              var playingsong:Sound = new Sound();

                              loadSongs();
                              loadplaylistbox();
                              loadSong(curtrack);
                              if (_root.autostart == "false") {
                                toggleplaypause();
                              }

                              function loadSongs() {
                              for (songIndex=0; songIndex<_root.playlistXml.childNodes[0].childNodes[0].childNodes.le ngth; songIndex++) {
                                var songdata:Object = new Object();
                                for (songNode=0; songNode<_root.playlistXml.childNodes[0].childNodes[0].childNodes[son gIndex].childNodes.length; songNode++) {
                                 switch(_root.playlistXml.childNodes[0].childNodes[0].childNodes[songI ndex].childNodes[songNode].nodeName){
                                 case "creator":
                                  songdata.artist = _root.playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].c hildNodes[songNode].childNodes[0].nodeValue;
                                  break;
                                 case "title":
                                  songdata.title = _root.playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].c hildNodes[songNode].childNodes[0].nodeValue;
                                  break;
                                 case "location":
                                  songdata.location = _root.playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].c hildNodes[songNode].childNodes[0].nodeValue;
                                  break;
                                 }
                                }
                                songs[songIndex] = songdata;
                              }
                              }
                              function loadSong(track) {
                              playingsong = new Sound();
                              playingsong.loadSound(songs[track].location, true);
                              playingsong.start(0);
                              updatevolume();
                              playingsong.onSoundComplete = function() {
                                loadSong((curtrack+1)%(songs.length));
                              };
                              playpause.gotoAndStop(1);
                              playpause.playpausebutton.onPress = function() {
                                toggleplaypause();
                              };
                              songdisplay.text = songs[track].artist+" - "+songs[track].title;
                              eval("playlistbox.playlistitemcontainer.playlistitem"+curtrack+".play listitemhighlight")._alpha = 100;
                              eval("playlistbox.playlistitemcontainer.playlistitem"+track+".playlis titemhighlight")._alpha = 1;
                              curtrack = track;
                              }
                              function loadplaylistbox() {
                              for (songIndex=0; songIndex<_root.playlistXml.childNodes[0].childNodes[0].childNodes.le ngth; songIndex++) {
                                playlistbox.playlistitemcontainer.attachMovie("playlistitem", "playlistitem"+songIndex, playlistbox.playlistitemcontainer.getNextHighestDepth(), {_x:0, _y:15*songIndex});
                                eval("playlistbox.playlistitemcontainer.playlistitem"+songIndex+".pla ylistitemtext").text = songs[songIndex].artist+" - "+songs[songIndex].title;
                                eval("playlistbox.playlistitemcontainer.playlistitem"+songIndex).song index = songIndex;
                              }
                              }
                              playpause.playpausebutton.onPress = function() {
                              toggleplaypause();
                              };
                              function toggleplaypause() {
                              if (playpause._currentframe == 1) {
                                playpause.gotoAndStop(2);
                                playpause.curpos = playingsong.position;
                                playingsong.stop();
                              } else {
                                playpause.gotoAndStop(1);
                                playingsong.start(playpause.curpos/1000, 0);
                              }
                              playpause.playpausebutton.onPress = function() {
                                toggleplaypause();
                              };
                              }
                              onEnterFrame = function () {
                              if (songdisplay.movingright) {
                                //songdisplay.hscroll -= 10;
                                if (songdisplay.hscroll<=0) {
                                 //songdisplay.movingright = false;
                                }
                              } else {
                                //songdisplay.hscroll += 10;
                                if (songdisplay.hscroll>=songdisplay.maxhscroll) {
                                 //songdisplay.movingright = true;
                                }
                              }
                              if (!draggingslider) {
                                progressslider._x = (playingsong.position/playingsong.duration)*182-89;
                                //if (progressslider._x == 0) {
                                 //progressslider._x = 61;
                                //}
                              }
                              if (draggingplaylistscroller) {
                                updateplaylistscroll();
                              }
                              if (draggingvolmeslider) {
                                updatevolume();
                              }
                              tempsongtime = "";
                              if (Math.floor(playingsong.position/60000) == 0) {
                                tempsongtime += "0";
                              } else {
                                tempsongtime += Math.floor(playingsong.position/60000);
                              }
                              tempsongtime += ":";
                              if (Math.floor((playingsong.position/1000)%60)<10) {
                                tempsongtime += "0";
                              }
                              tempsongtime += Math.floor((playingsong.position/1000)%60);
                              tempsongtime += "/";
                              if (Math.floor(playingsong.duration/60000) == 0) {
                                tempsongtime += "0";
                              } else {
                                tempsongtime += Math.floor(playingsong.duration/60000);
                              }
                              tempsongtime += ":";
                              if (Math.floor((playingsong.duration/1000)%60)<10) {
                                tempsongtime += "0";
                              }
                              tempsongtime += Math.floor((playingsong.duration/1000)%60);
                              songtime.text = tempsongtime;

                              };
                              progressslider.onPress = function() {
                              draggingslider = true;
                              progressslider.startDrag(true, -89, progressslider._y, 93, progressslider._y);
                              };
                              progressslider.onRelease = progressslider.onReleaseOutside=function () {
                              progressslider.stopDrag();
                              playingsong.start(((progressslider._x+89)/182)*playingsong.duration/1 000, 0);
                              playpause.gotoAndStop(1);
                              playpause.playpausebutton.onPress = function() {
                                toggleplaypause();
                              };
                              draggingslider = false;
                              };
                              progressbar.onPress = function() {
                              playingsong.start(((this._xmouse+2)/182)*playingsong.duration/1000, 0);
                              playpause.gotoAndStop(1);
                              playpause.playpausebutton.onPress = function() {
                                toggleplaypause();
                              };
                              };
                              volumebar.onPress = function() {
                              draggingvolmeslider = true;
                              volumebar.volumeslider.startDrag(true, 0, volumebar.volumeslider._y, 47, volumebar.volumeslider._y);
                              };
                              volumebar.onRelease = volumebar.onReleaseOutside=function () {
                              draggingvolmeslider = false;
                              volumebar.volumeslider.stopDrag();
                              updatevolume();
                              };
                              function updatevolume() {

                              trace((volumebar.volumeslider._x / 47) * 100+" : volumeSlider _x= "+volumebar.volumeslider._x)

                              playingsong.setVolume((volumebar.volumeslider._x/47)*100);
                              }
                              previoussong.onPress = function() {
                              loadprevioussong();
                              };
                              function loadprevioussong() {
                              var loadtrack = (curtrack-1)%(songs.length);
                              if (loadtrack<0) {
                                loadtrack = songs.length-1;
                              }
                              loadSong(loadtrack);
                              }
                              nextsong.onPress = function() {
                              loadnextsong();
                              };
                              function loadnextsong() {
                              var loadtrack = (curtrack+1)%(songs.length);
                              loadSong(loadtrack);
                              }
                              playlistscroller.onPress = function() {
                              draggingplaylistscroller = true;
                              playlistscroller.startDrag(true, 452, -80, 452, -59);
                              };
                              playlistscroller.onRelease = playlistscroller.onReleaseOutside=function () {
                              draggingplaylistscroller = false;
                              playlistscroller.stopDrag();
                              };
                              playlistscrollup.onPress = function() {
                              playlistscroller._y = Math.max(-80, playlistscroller._y-0.5);
                              updateplaylistscroll();
                              };
                              playlistscrolldown.onPress = function() {
                              playlistscroller._y = Math.min(-59, playlistscroller._y+0.5);
                              updateplaylistscroll();
                              };
                              var mouseListener:Object = new Object();
                              mouseListener.onMouseWheel = function(delta:Number) {
                              playlistscroller._y = Math.min(-59, Math.max(-80, playlistscroller._y-delta));
                              updateplaylistscroll();
                              };
                              Mouse.addListener(mouseListener);
                              playlistscrollbar.onPress = function() {
                              playlistscroller._y = Math.min(-59, Math.max(-80, _ymouse));
                              updateplaylistscroll();
                              };
                              function updateplaylistscroll() {
                              playlistbox.playlistitemcontainer._y = -((playlistscroller._y +80)/21)*(playlistbox.playlistitemcontainer._height-69);
                              }

                              • 12. Re: Adjust volume on autoplay with a playlist xml ?
                                Acidhunter Community Member

                                Thanks kglad,

                                so now i have this volume value here: volumeSlider _x= 29.05

                                 

                                So i update this part of the code here:

                                 

                                 

                                trace((volumebar.volumeslider._x / 47) * 100+" : volumeSlider _x= "+volumebar.volumeslider._x)

                                playingsong.setVolume((volumebar.volumeslider._x/47)*100);

                                 

                                 

                                with:

                                 

                                 

                                trace((volumebar.volumeslider._x / 47) * 100+" : volumeSlider _x= "+volumebar.volumeslider._x)

                                playingsong.setVolume((volumebar.volumeslider._x/29)*62); `

                                 

                                Or did i missunderstood something ?

                                • 13. Re: Adjust volume on autoplay with a playlist xml ?
                                  kglad CommunityMVP

                                  use:

                                   

                                   

                                  stop();
                                  var songs:Array = new Array();
                                  var curtrack:Number = 0;
                                  var playingsong:Sound = new Sound();

                                  volumebar.volumeslider._x = 29;

                                  updatevolume();

                                  loadSongs();
                                  loadplaylistbox();
                                  loadSong(curtrack);
                                  if (_root.autostart == "false") {
                                    toggleplaypause();
                                  }

                                  function loadSongs() {
                                  for (songIndex=0; songIndex<_root.playlistXml.childNodes[0].childNodes[0].childNodes.le ngth; songIndex++) {
                                    var songdata:Object = new Object();
                                    for (songNode=0; songNode<_root.playlistXml.childNodes[0].childNodes[0].childNodes[son gIndex].childNodes.length; songNode++) {
                                     switch(_root.playlistXml.childNodes[0].childNodes[0].childNodes[songI ndex].childNodes[songNode].nodeName){
                                     case "creator":
                                      songdata.artist = _root.playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].c hildNodes[songNode].childNodes[0].nodeValue;
                                      break;
                                     case "title":
                                      songdata.title = _root.playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].c hildNodes[songNode].childNodes[0].nodeValue;
                                      break;
                                     case "location":
                                      songdata.location = _root.playlistXml.childNodes[0].childNodes[0].childNodes[songIndex].c hildNodes[songNode].childNodes[0].nodeValue;
                                      break;
                                     }
                                    }
                                    songs[songIndex] = songdata;
                                  }
                                  }
                                  function loadSong(track) {
                                  playingsong = new Sound();
                                  playingsong.loadSound(songs[track].location, true);
                                  playingsong.start(0);
                                  updatevolume();
                                  playingsong.onSoundComplete = function() {
                                    loadSong((curtrack+1)%(songs.length));
                                  };
                                  playpause.gotoAndStop(1);
                                  playpause.playpausebutton.onPress = function() {
                                    toggleplaypause();
                                  };
                                  songdisplay.text = songs[track].artist+" - "+songs[track].title;
                                  eval("playlistbox.playlistitemcontainer.playlistitem"+curtrack+".play listitemhighlight")._alpha = 100;
                                  eval("playlistbox.playlistitemcontainer.playlistitem"+track+".playlis titemhighlight")._alpha = 1;
                                  curtrack = track;
                                  }
                                  function loadplaylistbox() {
                                  for (songIndex=0; songIndex<_root.playlistXml.childNodes[0].childNodes[0].childNodes.le ngth; songIndex++) {
                                    playlistbox.playlistitemcontainer.attachMovie("playlistitem", "playlistitem"+songIndex, playlistbox.playlistitemcontainer.getNextHighestDepth(), {_x:0, _y:15*songIndex});
                                    eval("playlistbox.playlistitemcontainer.playlistitem"+songIndex+".pla ylistitemtext").text = songs[songIndex].artist+" - "+songs[songIndex].title;
                                    eval("playlistbox.playlistitemcontainer.playlistitem"+songIndex).song index = songIndex;
                                  }
                                  }
                                  playpause.playpausebutton.onPress = function() {
                                  toggleplaypause();
                                  };
                                  function toggleplaypause() {
                                  if (playpause._currentframe == 1) {
                                    playpause.gotoAndStop(2);
                                    playpause.curpos = playingsong.position;
                                    playingsong.stop();
                                  } else {
                                    playpause.gotoAndStop(1);
                                    playingsong.start(playpause.curpos/1000, 0);
                                  }
                                  playpause.playpausebutton.onPress = function() {
                                    toggleplaypause();
                                  };
                                  }
                                  onEnterFrame = function () {
                                  if (songdisplay.movingright) {
                                    //songdisplay.hscroll -= 10;
                                    if (songdisplay.hscroll<=0) {
                                     //songdisplay.movingright = false;
                                    }
                                  } else {
                                    //songdisplay.hscroll += 10;
                                    if (songdisplay.hscroll>=songdisplay.maxhscroll) {
                                     //songdisplay.movingright = true;
                                    }
                                  }
                                  if (!draggingslider) {
                                    progressslider._x = (playingsong.position/playingsong.duration)*182-89;
                                    //if (progressslider._x == 0) {
                                     //progressslider._x = 61;
                                    //}
                                  }
                                  if (draggingplaylistscroller) {
                                    updateplaylistscroll();
                                  }
                                  if (draggingvolmeslider) {
                                    updatevolume();
                                  }
                                  tempsongtime = "";
                                  if (Math.floor(playingsong.position/60000) == 0) {
                                    tempsongtime += "0";
                                  } else {
                                    tempsongtime += Math.floor(playingsong.position/60000);
                                  }
                                  tempsongtime += ":";
                                  if (Math.floor((playingsong.position/1000)%60)<10) {
                                    tempsongtime += "0";
                                  }
                                  tempsongtime += Math.floor((playingsong.position/1000)%60);
                                  tempsongtime += "/";
                                  if (Math.floor(playingsong.duration/60000) == 0) {
                                    tempsongtime += "0";
                                  } else {
                                    tempsongtime += Math.floor(playingsong.duration/60000);
                                  }
                                  tempsongtime += ":";
                                  if (Math.floor((playingsong.duration/1000)%60)<10) {
                                    tempsongtime += "0";
                                  }
                                  tempsongtime += Math.floor((playingsong.duration/1000)%60);
                                  songtime.text = tempsongtime;

                                  };
                                  progressslider.onPress = function() {
                                  draggingslider = true;
                                  progressslider.startDrag(true, -89, progressslider._y, 93, progressslider._y);
                                  };
                                  progressslider.onRelease = progressslider.onReleaseOutside=function () {
                                  progressslider.stopDrag();
                                  playingsong.start(((progressslider._x+89)/182)*playingsong.duration/1 000, 0);
                                  playpause.gotoAndStop(1);
                                  playpause.playpausebutton.onPress = function() {
                                    toggleplaypause();
                                  };
                                  draggingslider = false;
                                  };
                                  progressbar.onPress = function() {
                                  playingsong.start(((this._xmouse+2)/182)*playingsong.duration/1000, 0);
                                  playpause.gotoAndStop(1);
                                  playpause.playpausebutton.onPress = function() {
                                    toggleplaypause();
                                  };
                                  };
                                  volumebar.onPress = function() {
                                  draggingvolmeslider = true;
                                  volumebar.volumeslider.startDrag(true, 0, volumebar.volumeslider._y, 47, volumebar.volumeslider._y);
                                  };
                                  volumebar.onRelease = volumebar.onReleaseOutside=function () {
                                  draggingvolmeslider = false;
                                  volumebar.volumeslider.stopDrag();
                                  updatevolume();
                                  };
                                  function updatevolume() {

                                  // trace((volumebar.volumeslider._x / 47) * 100+" : volumeSlider _x= "+volumebar.volumeslider._x)  <- no longer needed

                                  playingsong.setVolume((volumebar.volumeslider._x/47)*100);
                                  }
                                  previoussong.onPress = function() {
                                  loadprevioussong();
                                  };
                                  function loadprevioussong() {
                                  var loadtrack = (curtrack-1)%(songs.length);
                                  if (loadtrack<0) {
                                    loadtrack = songs.length-1;
                                  }
                                  loadSong(loadtrack);
                                  }
                                  nextsong.onPress = function() {
                                  loadnextsong();
                                  };
                                  function loadnextsong() {
                                  var loadtrack = (curtrack+1)%(songs.length);
                                  loadSong(loadtrack);
                                  }
                                  playlistscroller.onPress = function() {
                                  draggingplaylistscroller = true;
                                  playlistscroller.startDrag(true, 452, -80, 452, -59);
                                  };
                                  playlistscroller.onRelease = playlistscroller.onReleaseOutside=function () {
                                  draggingplaylistscroller = false;
                                  playlistscroller.stopDrag();
                                  };
                                  playlistscrollup.onPress = function() {
                                  playlistscroller._y = Math.max(-80, playlistscroller._y-0.5);
                                  updateplaylistscroll();
                                  };
                                  playlistscrolldown.onPress = function() {
                                  playlistscroller._y = Math.min(-59, playlistscroller._y+0.5);
                                  updateplaylistscroll();
                                  };
                                  var mouseListener:Object = new Object();
                                  mouseListener.onMouseWheel = function(delta:Number) {
                                  playlistscroller._y = Math.min(-59, Math.max(-80, playlistscroller._y-delta));
                                  updateplaylistscroll();
                                  };
                                  Mouse.addListener(mouseListener);
                                  playlistscrollbar.onPress = function() {
                                  playlistscroller._y = Math.min(-59, Math.max(-80, _ymouse));
                                  updateplaylistscroll();
                                  };
                                  function updateplaylistscroll() {
                                  playlistbox.playlistitemcontainer._y = -((playlistscroller._y +80)/21)*(playlistbox.playlistitemcontainer._height-69);
                                  }

                                  • 14. Re: Adjust volume on autoplay with a playlist xml ?
                                    Acidhunter Community Member

                                    thats excellent kglad !  it adjust the volume now on the slider

                                     

                                    But now another problem showed up !

                                    Around 4 to 5 sec after the sound have played , i can hear that it sudenly become a bit louder.

                                    Do you have any idea what that can be who cause this ?

                                    I uploaded the swf so you can hear it by yourself on my test page. 

                                     

                                    Thanks Again.

                                    • 15. Re: Adjust volume on autoplay with a playlist xml ?
                                      kglad CommunityMVP

                                      uncomment that trace() statement in updatevolume() to see if something is calling that function around the 4-5 sec mark when you hear the volume increase.

                                      • 16. Re: Adjust volume on autoplay with a playlist xml ?
                                        Acidhunter Community Member

                                        It Works like a charm now after i uncomment the  updatevolume() to only updatevolume

                                         

                                        Thank you very much kglad

                                         

                                        Problem solved

                                        • 17. Re: Adjust volume on autoplay with a playlist xml ?
                                          kglad CommunityMVP

                                          you're welcome.