function play_sound_1(){
var audio1 = new Audio ('audio/1.mp3');
audio1.autoplay = true;
// отключить play_sound_2()
}
function play_sound_2(){
var audio2 = new Audio ('audio/2.mp3');
audio2.autoplay = true;
// отключить play_sound_1()
}
function play_sound_1(){
var audio1 = new Audio ('audio/1.mp3');
audio1.autoplay = true;
play_sound_2 = e => {};
}
function play_sound_2(){
var audio2 = new Audio ('audio/2.mp3');
audio2.autoplay = true;
play_sound_1 = e => {};
}
var is_sound_played = 0;
function play_sound_1(){
if (is_sound_played === 2) return;
is_sound_played = 1;
var audio1 = new Audio ('audio/1.mp3');
audio1.autoplay = true;
}
function play_sound_2(){
if (is_sound_played === 1) return;
is_sound_played = 2;
var audio2 = new Audio ('audio/2.mp3');
audio2.autoplay = true;
}
var audio1,audio2;//объекты звуков
function stop_play(){
if(audio1)audio1.stop();//отключаем первый звук если он был
if(audio2)audio2.stop();//отключаем второй звук если он был
audio1=undefined;
audio2=undefined;
}
function play_sound_1(){
stop_play();
audio1 = new Audio ('audio/1.mp3');
audio1.autoplay = true;
}
function play_sound_2(){
stop_play();
audio2 = new Audio ('audio/2.mp3');
audio2.autoplay = true;
}