gpt4 book ai didi

javascript 音频语法可能是错误的?

转载 作者:行者123 更新时间:2023-12-03 07:17:03 24 4
gpt4 key购买 nike

它不播放声音。我见过 javascript 音频的不同语法公式,现在我有点不确定什么是正确的,什么是错误的。我猜问题出在新的音频位上,因为我不确定这是否正确。感谢您的帮助。

var greenSound = new Audio('<https://s3.amazonaws.com/freecodecamp/simonSound1.mp3>');
var redSound = new Audio('<https://s3.amazonaws.com/freecodecamp/simonSound2.mp3>');
var blueSound = new Audio('<https://s3.amazonaws.com/freecodecamp/simonSound3.mp3>');
var yellowSound = new Audio('<https://s3.amazonaws.com/freecodecamp/simonSound4.mp3>');
var sounds = [greenSound, redSound, blueSound, yellowSound];
var soundNums = [];


num = Math.floor(4*Math.random());
simon.push(moves[num]);
soundNums.push(num);
for(var i = 0; i < simon.length; i++)
{
$(simon[i]).fadeOut(200).fadeIn(200);
(sounds[soundNums[i]]).play();
}

最佳答案

一切正常,但 URL 存在语法问题。

由此:

var mp3 = new Audio('<https://s3.amazonaws.com/freecodecamp/simonSound1.mp3>');

为此:

var mp3 = new Audio('https://s3.amazonaws.com/freecodecamp/simonSound1.mp3');

关于javascript 音频语法可能是错误的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36380048/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com