Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 控制Jquery音频播放器的Jquery滑块_Javascript_Jquery_Html_Audio - Fatal编程技术网

Javascript 控制Jquery音频播放器的Jquery滑块

Javascript 控制Jquery音频播放器的Jquery滑块,javascript,jquery,html,audio,Javascript,Jquery,Html,Audio,我正在为jquery播放器开发一个音频滑块,目标是让音频滑块控制音量。音频播放器是使用Jquery而不是音频标签启动的,并且具有类。出于某种原因,播放滑块不会改变音量 编辑:工作解决方案- JS小提琴: 我换了。播放选择器到var thissound,它就工作了 工作小提琴: $(".play").on('click', function () { var key = $(this).attr('key'); EvalSound(this, key); var t

我正在为jquery播放器开发一个音频滑块,目标是让音频滑块控制音量。音频播放器是使用Jquery而不是音频标签启动的,并且具有类。出于某种原因,播放滑块不会改变音量

编辑:工作解决方案-

JS小提琴:


我换了。播放选择器到var thissound,它就工作了

工作小提琴:

 $(".play").on('click', function () {
     var key = $(this).attr('key');
     EvalSound(this, key);
     var this_play = $(this);
     $(".play").each(function () {
         if ($(this)[0] != this_play[0]) {
             $(this).removeClass("pause");
         }
     });
     $(this).toggleClass("pause");
 });

 var thissound = new Audio();
 var currentKey;

 function EvalSound(el, key) {

     thissound.addEventListener('ended', function () {
         // done playing
         $(el).removeClass("pause");
     });

     if (currentKey !== key) thissound.src = "http://99centbeats.com/1e4cb5f584d055a0992385c1b2155786/" + key + ".mp3";
     currentKey = key;

     if (thissound.paused) thissound.play();
     else thissound.pause();
     thissound.currentTime = 0;
     currentPlayer = thissound;


 }
$(".volume_slider").slider({
    value  : 75,
    step   : 1,
    range  : 'min',
    min    : 0,
    max    : 100,
    slide  : function(){
        var value = $(".volume_slider").slider("value");
        $('.play').prop('volume', (value/100));
    }
});
$(".play").on('click', function () {
     var key = $(this).attr('key');
     EvalSound(this, key);
     var this_play = $(this);
     $(".play").each(function () {
         if ($(this)[0] != this_play[0]) {
             $(this).removeClass("pause");
         }
     });
     $(this).toggleClass("pause");
 });

 var thissound = new Audio();
 var currentKey;

 function EvalSound(el, key) {

     thissound.addEventListener('ended', function () {
         // done playing
         $(el).removeClass("pause");
     });

     if (currentKey !== key) thissound.src = "http://99centbeats.com/1e4cb5f584d055a0992385c1b2155786/" + key + ".mp3";
     currentKey = key;

     if (thissound.paused) thissound.play();
     else thissound.pause();
     thissound.currentTime = 0;
     currentPlayer = thissound;


 }
$(".volume_slider").slider({
    value  : 75,
    step   : 1,
    range  : 'min',
    min    : 0,
    max    : 100,
    slide  : function(){
        var value = $(".volume_slider").slider("value");
        thissound.volume = (value / 100);
    }
});