P5.JS-preload()问题

时间:2018-12-13 19:20:05

标签: javascript p5.js

我尝试在浏览器中播放歌曲。 当我运行html时,会发生以下情况: “未捕获的文件尚未准备好播放,缓冲区尚未加载。请尝试preload()”

HTML:

<!doctype>
<html>
    <head>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.2/p5.js"></script>
        <script src="p5.js-master/p5.js-master/lib/addons/p5.sound.js"></script>
        <script src="sketch.js"></script>
    </head>
    <body>

    </body>
</html>

sketch.js:


    var song;
    function preload() { 

    song = loadSound("song.mp3");

    }

    function setup() {

        createCanvas(100,100);
        song.play();
    }

    function draw() {
        background(0);
    }

帮助!

0 个答案:

没有答案