Chrome汽车政策在2018年4月发生了变化。 我愿利用其中的一项政策: 如果用户与领域(浮标、主线等)互动,则允许与声音自动交换。 因此,我有一个网页。
<a href="d2.php">dictation</a>
当用户在上页上点击链接时,第二页(d2.php)被装上。 其内容如下:
<!DOCTYPE html>
<html>
<body>
<h1>The audio autoplay attribute</h1>
<p>Click on the play button to play a sound:</p>
<audio controls autoplay>
<source src="https://www.w3schools.com/tags/horse.ogg" type="audio/ogg">
<source src="https://www.w3schools.com/tags/horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</body>
</html>
The audio autoplay works on Chrome as expected. Also it can be verified that the autoplay works with Edge and Opera. However,
- It does not work with Firefox 117.0.1 (64-bit), ie, audio is not autoplayed.
- With a version of Safari I installed on my Ubuntu using WINE, it give me "Your browser does not support the audio element." message.
I would consider the Safari message is caused by my Ubuntu - WINE installation. However, could anybody help me with the firefox audio autoplay? I am open to any solution with HTML, PHP, and JaveScript. Thanks in advance.
PS:我阅读了许多因特网上的“html声自动”节目。