服务器对音频文件的请求在返回任何数据之前超时

Server request for audio file times out before returning any data

当 运行 检索音频文件的代码时,我收到此错误:

Failed to load resource: net::ERR_CONNECTION_TIMED_OUT

我很确定这意味着加载超时的资源需要很长时间。但我不确定为什么会这样。我检查以确保它正在加载正确的文件,确实如此。

这是html代码

<html>

<head>
    <style>
        .titletext {
            color: white;
            display: block;
            position: absolute;
            font-size: 50px;
            width: 1000px;
            margin-left: 150px;
            margin-right: 200px;
        }

        .nametext {
            color: white;
            display: block;
            position: absolute;
            font-size: 30px;
            width: 600px;
            margin-left: 500px;
            margin-right: 200px;
            margin-top: 600px;
        }

        .earthphoto {
            display: block;
            position: absolute;
            margin-left: 400px;
            margin-top: 150px;
        }
    </style>
</head>

<body onresize="changeWidth()" onload="changeWidth()">
    <script type="text/javascript">
        document.body.style.background = "black";
        var changeWidth = function() {
            screenwidth = window.innerWidth;
            screenheight = window.innerHeight;
        };
        var changescene = function() {
            var allvariables = Object.keys(window);
            if (page === 1) {
                allvariables.splice(9, 4);
            }
            page++;
        };
        var page = 1;
        document.body.addEventListener("click", function() {
            changescene()
        });

        var update = function() {
            if (page === 1) {
                document.body.innerHTML = "";
                var text = document.createElement("p");
                var textclass = document.createAttribute("class");
                textclass.value = "titletext";
                text.setAttributeNode(textclass);
                text.appendChild(document.createTextNode("Welcome to Mikey's Google Earth Presentation!"));
                document.body.appendChild(text);
                var text2 = document.createElement("p");
                text2class = document.createAttribute("class");
                text2class.value = "nametext";
                text2.setAttributeNode(text2class);
                text2.appendChild(document.createTextNode("By Mikey Richards"));
                document.body.appendChild(text2);
                googleearthimage = document.createElement("img");
                googleearthimage.setAttribute("src", "EARTH.png");
                googleearthimage.setAttribute("class", "earthphoto");
                document.body.appendChild(googleearthimage);
                var music = document.createElement("audio");
                var musiclink = document.createElement("source");
                musiclink.src = "Test.mp3";
                music.appendChild(musiclink);
                document.body.appendChild(music);
            } else if (page === 2) {
                document.body.innerHTML = "";
            }
        }
        setInterval(function() {
            update();
        }, 1000);
    </script>
</body>

</html>

可以找到此代码的网站 here

好的。我发现他的问题是我没有在音频上调用播放功能。感谢您容忍我糟糕的编程技巧。