how to autoplay audio?

Started by Daintree, April 06, 2020, 11:19:12 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Daintree

How to autoplay audio, when the page is loaded?

I have tried put autoplay in the audio tag, and it didn't work.

<audio id="audio" autoplay>
  <source src="audio/dark-tense-piano-drone.mp3" type="audio/mp3">
</audio>
and I have tried

$(document).ready(function() {
  $("#audio").get(0).play();
  $('#audio').prop("volume", 0.2);
}
then it didn't work.

Is there any other idea to autoplay audio, when the page is loaded?


Hackoo

I tested this under IE Edge and it works 5/5  ;)
And with HTA file too  :-*

<!DOCTYPE html>
<meta http-equiv="x-ua-compatible" content="ie=9">
<html>
<head>
<script>
window.onload = function AutoPlay() {
document.getElementById("my_audio").load();
document.getElementById("my_audio").play();
}
</script>
</head>
<body>
<center>
<audio id="my_audio" src="http://listen.pioneerdjradio.com:8550/stream/1/" type="audio/mpeg"></audio>
</center>
</body>
</html>

devendraraju

Quote from: Hackoo on April 20, 2020, 02:09:17 AM
You can take a look at this ==> Playing audio after the page loads in html
The page of Stack overflow will help you. Like it helped me