Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: how to autoplay audio?  (Read 117464 times)

0 Members and 1 Guest are viewing this topic.

Daintree

  • Guest
how to autoplay audio?
« on: April 06, 2020, 11:19:12 PM »
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



    Hopeful
  • Thanked: 42
  • Experience: Expert
  • OS: Windows 10
Re: how to autoplay audio?
« Reply #1 on: April 20, 2020, 02:09:17 AM »
You can take a look at this ==> Playing audio after the page loads in html

Hackoo



    Hopeful
  • Thanked: 42
  • Experience: Expert
  • OS: Windows 10
Re: how to autoplay audio?
« Reply #2 on: April 20, 2020, 03:21:36 AM »
I tested this under IE Edge and it works 5/5  ;)
And with HTA file too  :-*

Code: [Select]
<!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

  • Guest
Re: how to autoplay audio?
« Reply #3 on: April 22, 2020, 11:07:41 PM »
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