+ 2

How to Play sound file in a web-page in the background Automatically when the webpage open??

I want to play a sound file on my web-page in the back-ground(don't want Media player UI to appear), my web-site will run on Fire-Fox, i used the Embed element and set the Hidden attribute to be true <embed name="myMusic" src="Masgon.mp3" type="audio/midi" autostart="false" Hidden="true" loop="true"></embed> the problem is that no sound is played unless i removed the hidden attribute on this case the sound file is played and the media player UI appears but i don't want that.

13th Jan 2019, 10:40 AM
Sonu Kumar
Sonu Kumar - avatar
10 Respostas
+ 4
Lucky Luke I mean where should i store audio file to use it in sololearn playground? Can i use my googgle drive ?
13th Jan 2019, 11:05 AM
Sonu Kumar
Sonu Kumar - avatar
+ 3
Can i add music from any website directly
13th Jan 2019, 11:01 AM
Sonu Kumar
Sonu Kumar - avatar
+ 3
Lucky Luke i was tried many times in different way to link this file (mp3) but i fail to play it on browser . There were no sound..
13th Jan 2019, 11:15 AM
Sonu Kumar
Sonu Kumar - avatar
+ 3
Lucky Luke if i remove the hidden attribure and store the music file in source folder , (using visual studio code ) then it work properly but if i use it on sololearn code playground from my drive or any other sourse like ganna.com then i am fail to play .
13th Jan 2019, 11:22 AM
Sonu Kumar
Sonu Kumar - avatar
+ 1
You can use the audio element. https://www.sololearn.com/learn/HTML/2193/ If you don't want it to appear, you can try setting visibility: hidden in the CSS rules. You can add the autoplay attribute to make it start playing as soon as the page loads.
13th Jan 2019, 10:58 AM
giannismach
giannismach - avatar
0
Sonu Kumar What exactly do you mean?
13th Jan 2019, 11:02 AM
giannismach
giannismach - avatar
0
Sonu Kumar To tell you the truth, I don't know, but I can't think of any other way. You can try it to see if it works.
13th Jan 2019, 11:10 AM
giannismach
giannismach - avatar
0
Delete the visibility: hidden rule and see if an audio element appears. If it appears, try to play the music.
13th Jan 2019, 11:17 AM
giannismach
giannismach - avatar
0
Then you need a different approach. Check out this code which uses background music (especially the song and change functions) https://code.sololearn.com/Wis4OmrSYmM9/?ref=app
13th Jan 2019, 11:25 AM
giannismach
giannismach - avatar
0
Try setting "autostart: true" .
31st Jan 2019, 11:33 AM
Jaime Alvarez