Я седел писал код чтобы при правильном ответе играла полложительняя музыка а при не правильном ответе играла отрицательня музака во кусочек кода подскажите почему не работает[JS]
var GLOBAL_STATE = {
"status": "stopped",
"voice": true,
"voice_comment": true,
"show_numbers": true,
"show_true_false": true,
"show_example_number": false,
"competition_mode": false,
"modes": ["default"],
"timer": undefined,
"additional_timer": undefined,
"counter": 3,
"interval": 1,
"all_points_100": 0,
'double_sign_mode': false
};
function getInternetExplorerVersion() {
var rv = -1;
if (navigator.appName == 'Microsoft Internet Explorer') {
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat(RegExp.$1);
} else if (navigator.appName == 'Netscape') {
var ua = navigator.userAgent;
var re = new RegExp("Trident/.*rv
[0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat(RegExp.$1);
}
return rv;
}
function ajax_get_parameters() {
$.ajax({
type: "get",
url: $("#task_parameters_url").val(),
success: function (data) {
for (var i = 1; i <= GLOBAL_STATE.screens_nmb; i++) {
GLOBAL_STATE[i].parameters = get_parameters_parsed(data.parameters);
}
set_setting_bars(GLOBAL_STATE[1], 1, true);
$('#main_screen').removeClass('d-none');
}
})
}
function is_task_mode() {
return ($("#main_screen").data("type") === "task")
}
$(document).ready(function () {
if (is_task_mode()) {
$('#main_screen').addClass('d-none');
ajax_get_parameters()
}
});
function get_parameters() {
parameters = $("#modal_global_settings").find("form").serialize Object();
return get_parameters_parsed(parameters)
}
function change_bg() {
random_number = random_between(1, 80);
var image_fon = "bg_" + random_number + ".jpg";
image_url = '/static/img/backgrounds/' + image_fon;
$('#main_screen').css('background-image', 'url(' + image_url + ')');
}
function playSound(sound, i, newVoice) {
var soundHowl;
switch (sound) {
case 'tik-tak':
break;
case 'countdown':
if (i === 0) {
sound_click(sound);
} else {
soundHowl = new Howl({
src: [`/static/games_audio/new/sounds/${sound}.mp3`],
});
soundHowl.play();
}
break;
case 'click':
case 'error':
case 'success':
soundHowl = new Howl({
src: [`/static/games_audio/new/sounds/${sound}.mp3`],
});
soundHowl.play();
break;
case 'successMusic':
case 'errorMusic':
case 'presentMusic':
break;
default:
filename = sound.replace("+", "plus_").replace("-", "minus_");
number = parseInt(sound);
absNumber = Math.abs(number);
switch (lang) {
case 'ru':
voiceUrl = '/static/games_audio/new/numbers/ru2/';
break;
case 'ukr':
voiceUrl = '/static/games_audio/new/numbers/ukr/';
break;
case 'eng':
voiceUrl = '/static/games_audio/new/numbers/eng/';
break;
case 'rom':
voiceUrl = '/static/games_audio/new/numbers/rom/';
break;
}
if (newVoice) {
sound_interval = 270;
if (number > 0) {
sound_interval = 220;
}
if (absNumber >= 100 && absNumber < 1000) {
if (number > 0) {
sound_interval = 550;
}
if (absNumber % 100 === 0) {
soundHowl = new Howl({
src: [`${voiceUrl}${sound}.mp3`],
});
soundHowl.play();
} else {
if (sound.indexOf('+') !== -1) {
decades = absNumber % 100;
hundreds = absNumber - decades;
soundHowl = new Howl({
src: [`${voiceUrl}+${hundreds}_.mp3`],
});
soundHowl.play();
decadesDuration = parseInt(soundHowl.duration() * 1000);
setTimeout(function () {
soundHowl = new Howl({
src: [`${voiceUrl}${decades}.mp3`],
});
soundHowl.play();
}, decadesDuration - 20)
} else if (sound.indexOf('-') !== -1) {
decades = absNumber % 100;
hundreds = absNumber - decades;
soundHowl = new Howl({
src: [`${voiceUrl}-${hundreds}_.mp3`],
});
soundHowl.play();
decadesDuration = parseInt(soundHowl.duration() * 1000);
setTimeout(function () {
soundHowl = new Howl({
src: [`${voiceUrl}${decades}.mp3`],
});
soundHowl.play();
}, decadesDuration - 20)
} else {