Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
OOAAHH authored Oct 24, 2024
1 parent fedba30 commit 1a2c1fb
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,26 @@ All of those images' name should be replaced as followed.



<audio controls>
<audio id="background-audio" autoplay muted>
<source src="music/Retirement.mp3" type="audio/mp3">
</audio>

<script>
document.addEventListener("DOMContentLoaded", function() {
var audio = document.getElementById("background-audio");

// 尝试自动播放
var playPromise = audio.play();

if (playPromise !== undefined) {
playPromise.then(function() {
// 如果成功,去掉静音
audio.muted = false;
}).catch(function(error) {
// 如果失败,等待用户交互再播放
console.log("自动播放被阻止,需要用户交互");
});
}
});
</script>

0 comments on commit 1a2c1fb

Please sign in to comment.