Advertisement
KiberInfinity

VK AudioVolume

Jun 8th, 2012
129
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. vk_audioVolume={
  2.    step:10, // default step for inc & dec functions
  3.    inc:function(val){
  4.       var player = window.audioPlayer.player;
  5.       var step=val?val:vk_audioVolume.step;
  6.       var vol=player.getVolume()*100;
  7.       player.setVolume(Math.min(vol+step,100)/100);
  8.       vk_audioVolume.upd_view();
  9.    },
  10.    dec:function(val){
  11.       var player = window.audioPlayer.player;
  12.       var step=val?val:vk_audioVolume.step;
  13.       var vol=player.getVolume()*100;
  14.       player.setVolume(Math.max(vol-step,0)/100);
  15.       vk_audioVolume.upd_view();
  16.    },
  17.    set:function(vol){
  18.       var player = window.audioPlayer.player;
  19.       vol=vol>100?100:(vol<0?0:vol);
  20.       player.setVolume(vol/100);
  21.       vk_audioVolume.upd_view();
  22.    },
  23.    upd_view:function(){
  24.       var ge=window.ge;
  25.       var _a=window.audioPlayer;
  26.       var el=ge('audio_vol'+_a.id);
  27.       var vol=Math.round(_a.volW*_a.player.getVolume());
  28.       if (ge('audio_volume_line'+_a.id))
  29.             ge('audio_vol_slider'+_a.id).style.left=vol+'px';
  30.       if (ge('gp_vol_slider'))
  31.             ge('gp_vol_slider').style.left=vol+'px';
  32.    }
  33. }
  34.  
  35. // USE EXAMPLES
  36.  
  37. vk_audioVolume.inc();   // INCREASE VOLUME
  38. vk_audioVolume.dec();   // DECREASE
  39. vk_audioVolume.dec(10); // VOLUME - 10%
  40. vk_audioVolume.inc(20); // VOLUME + 20%
  41. vk_audioVolume.set(0);  // 0% VOLUME
  42. vk_audioVolume.set(50); // 50% VOLUME
Advertisement
RAW Paste Data Copied
Advertisement