javascript - how to preload an audio in html before showing the content to the user -


this question has answer here:

i have page full of css animations , important me have music beginning. i've used call music. here code:

<body> <audio  autoplay> <source src="./1.mp3" type="audio/mpeg"> <source src="./1.ogg" type="audio/ogg"> <embed height="50" width="100" src="./1.mp3"> </audio> </body 

so how can preload music (and images too) , show whole page users @ once?

create js preloader , show page after content ready

the simplest way create preloading div @ top of page , hide after music loaded. or can wait not music, of content, how wish

#preloadingdiv {   position: absolute;   top: 0;   left: 0;   padding: 0;   margin: 0;   border: 0;   width: 100%;   z-index: 100; }  $("#preloaderdiv").css("height", window.innerheight + "px");  $("#music").load(function() {   $("#preloadingdiv").css("display", "none");   $("#musicplayer").get(0).play(); }); 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -