如何在第二次警报中播放第二个音频?我上载了网站,以作为我要尝试的示例。视频播放3秒后,我试图使警报出现。我已经做了。我只需要知道如何获取音频“sorry.wav?.wav?.wav”来播放第二个警报,“我有东西在吗?”
我根本不了解javascript,因此请告诉我特定代码进入当前代码的位置,因为我根本不知道。
另外,此网站是用于艺术创作的,因此,如果这不道德或奇怪,我对此表示歉意,但此项目需要将音频附加到警报中,反之亦然。
当前页面示例:
http://www.eves.website/second-original.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>eve_</title>
<link rel="icon" rel="preload" href="images/evecircle.png" />
<style>
#video {
margin-left:-10px;
margin-top:-10px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<style type="text/css">
body {
overflow:hidden;
}
</style>
<body onload="delayedAlert();">
<script>
var timeoutID;
function delayedAlert() {
timeoutID = window.setTimeout(slowAlert, 3000);
then.getElementsByTagName('audiotwo')[0];
}
function slowAlert() {
var audio= document.getElementsByTagName('audio')[0];
audio.play();
var myvar1;alert('Hello?')
audio.play();
var myvar2;alert('Is something here with me?');
}
</script>
<audio>
<source src="images/hellllloooo.wav" type="audio/wav" preload=true>
</audio>
<audiotwo>
<source src="images/sorry.wav?.wav?.wav" type="audio/wav" preload=true>
</audiotwo>
<video autoplay="autoplay" preload="auto" id="video" src="images/secondnew.mp4" width="1300px" height="auto" style="position:absolute; z-index:-1;" >
Video not supported.
</video>
</body>
</html>
最佳答案
<audiotwo>
不是有效的HTML,请将其也称为audio
,并确保src
的格式正确:
<audio>
<source src="images/sorry.wav?.wav?.wav" type="audio/wav" preload=true>
</audio>
(真的是
images/sorry.wav?.wav?.wav
吗?尝试修复文件名)然后通过选择它
const audio2 = document.getElementsByTagName('audio')[1];
一起玩
audio2.play();
(用
audio.play();
替换alert('Is something here with me?');
之前的第二个audio2.play();
)