jQuery audio volume per unique instance
I have a series of html5 audio player (dynamica开发者_Go百科lly generated), that I adjust the volume with a jquery slider. The problem I am having is that moving one slider changes the audio output volume for all. It does not change each instances audio setting. I wonder if anyone could help me with this, so that it only effect the audio player it is tied to.
//volume audio
$(document).ready(function () {
audio = $("#<?php echo $track_id; ?>").get(0);
audio.volume =<?php echo $trackVolume; ?>;
$("#volumeAudio<?php echo $track_id; ?>").each(function() {
$( this ).empty().slider({
value: <?php echo $trackVolume; ?>,
orientation: "horizontal",
range: "min",
max: 1,
step: 0.1,
animate: true,
slide: function( event, ui ) {
audio.volume = ui.value;
$.post(
"processForms/process_presentation.php", { presentationProcessing: 'updateAudioSliderVolume', presentationId: <?php echo $pres_id; ?>, trackID: <?php echo $track_id; ?>, sliderValueVolume: ui.value}
);
}
});
});
});
Change
audio.volume = ui.value;
To
$("#<?php echo $track_id; ?>").get(0).volume = ui.value;
精彩评论