PDA

View Full Version : How to play sound, music, intro or speech after website load?



Fli
05-22-2014, 08:50 PM
Hi,

do you have good tips on how to auto play music or some sound after a webpage is opened?

So far i found this code to be working good:

for mp3


<audio autoplay>
<source src="song.mp3" type="audio/mpeg">
</audio>


for ogg


<audio autoplay>
<source src="song.ogg" type="audio/ogg">
</audio>


just add to a webpage code. make sure audio file is in same folder as webpage file, you can also set path like /sounds/song.mp3 ---> source src="/sounds/song.mp3" and that means you need to add your song into yourdomain.com/sounds/ folder.

Example auto play sound you can find at website: http://hostinghostgatorcoupons.com/
The voice is created by: http://www.ivona.com/en/ (speaker is: Joey)
I just let him speak it and being recording by audio recorder software.

Hexajob
03-15-2016, 04:40 AM
Html 5 offers this facility to play music after loading the website

bondj9433
04-13-2016, 10:21 AM
Html 5 offers this facility :)
apis development (http://ranksol.com/xml-apis//) | application programmers (http://ranksol.com/xml-apis//) | api application (http://ranksol.com/xml-apis//)

Fantasysure
02-02-2021, 10:11 AM
Html 5 offers this facility to play music after loading the website

Sports Prediction (https://fantasysure.com/category/cricket-predictions/)

Gimli
02-05-2021, 01:04 PM
document.addEventListener('DOMContentLoaded', function() {
// your code here
}, false);
or if your comfort with jquery,

$(document).ready(function(){
// your code
});

$(document).ready() fires on DOMContent Loaded, but this event is not being fired consistently among browsers. This is why jQuery will most probably implement some heavy workarounds to support all the browsers. And this will make it very difficult to "exactly" simulate the behavior using plain Javascript (but not impossible of course).

as Jeffrey Sweeney and New Perspective design suggested, i think its better to have a setTimeout function on the website (https://www.newperspectivestudio.co.za/web-design-in-east-london.html), before firing the function like below :

setTimeout(function(){
//your code here
}, 3000);