我该怎么做才能让画布在不同的浏览器中工作[关闭]

问题描述 投票:-1回答:1

我正试图为我的网站获得一个漂亮的收音机,一切都适用于铬(大多数)。但是这段代码在firefox或edge中不起作用。我相信画布本身正在工作,因为我的网页有黑色背景,除了铬之外的所有东西都显示为白色。只是画布没有做任何应该做的事情。

我该怎么办才能修复它?

以下是与画布有关的一切。它从HTML音频元素中提取歌曲并继续创建音频可视化工具。

码:

<!DOCTYPE html>
<html>

<head>
  <link rel="stylesheet" href="scripts/radio.css">
</head>

<body>
  <canvas id="canvas"></canvas>
  <p class="songName" id="songName"></p>
  <audio id="playMusic" controls="controls" autoplay="autoplay">
         <source id="source" src="" type="audio/mp3">
         Your browser does not support the audio element.
      </audio>
  <button class="skip" id="skip" style="position: absolute;" onclick="skip()">Skip Song</button>
  <br />
  <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
  <script src="scripts/radio.js"></script>
</body>

</html>
canvas web-audio-api
1个回答
-1
投票

我发现了我面临的问题。有一个空的'src =“”'导致edge和firefox出错,但是没有chrome,它无法加载画布。

<source id="source" src="" type="audio/mp3">//Results in an error loading media because there is no source.
© www.soinside.com 2019 - 2024. All rights reserved.