Я пытаюсь заставить myMusic, извлеченный из моего файла .html, запускаться в цикле после запуска функции запуска игры, и я не могу понять, как это сделать.Я полагаю, что должно быть что-то, что я могу сделать в функции startgame для myMusic.play ();но я не могу понять это.любая помощь будет оценена.
var myMusic = document.getElementById("myMusic");
var myStartSound = document.getElementById("myStartSound");
var myWinSound = document.getElementById("myWinSound");
var myLoseSound = document.getElementById("myLoseSound");
var themeMusic = document.getElementById("themeMusic");
var audio = new Audio("./assets/Sounds/Halo theme.mp3");
window.onload = function(){
audio.play()
.then(function () {
console.log("ahhhhh");
})
.catch(function (err) {
console.log(err);
audio.currentTime = 1;
audio.play()
.then(function () {
console.log("ahhhhh");
})
.catch(function (err) {
console.log(err);
audio.currentTime = 1;
audio.play()
})
})
}
//alphabet array
var alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
];
//array for users guessed letters
var guessedLetter = [];
//array for users correct guesses
var correctLetter = [];
//guessed letters that are incorrect
var incorrectGuess = [];
//Below is the functionality of the game
function startGame() {
numGuesses = 12;
blanksAndSuccess = [];
guessedLetter = [];
incorrectGuess = [];
audio.pause();
myMusic.play()
.then(function () {
console.log("ahhhhh");
})
.catch(function (err) {