Skip to content

Commit

Permalink
Merge pull request #1 from nexoscreation/nexoscreator-patch-1
Browse files Browse the repository at this point in the history
up: autoplay when page load
  • Loading branch information
nexoscreator authored Jul 13, 2024
2 parents bd56d5b + 225ba5f commit e285e8f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ <h3 id="artist"></h3>
</div>
</div>
<script src="./js/main.js"></script>
<script src="./js/autoplay.js"></script>
</body>

</html>
</html>
9 changes: 9 additions & 0 deletions js/autoplay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
document.addEventListener("DOMContentLoaded", function() {
const musicPlayer = document.getElementById("disc");

// Autoplay the music when the page loads
musicPlayer.play().catch(error => {
console.error("Autoplay failed:", error);
// Autoplay might fail due to browser restrictions, inform the user if needed.
});
});

0 comments on commit e285e8f

Please sign in to comment.