I am trying to set sound on web page.
I found this code. It is working code when the div
is visible but I want to be hidden and working. In this case it is not working because it is hidden with style
attribute. How to make it not visible and playing sound at the same time ?
<div style="display:none">
<embed src="sound.mp3"/>
</div>
You can specify either 'hidden' (without value) or 'hidden="hidden"'. Both are valid. A hidden <audio> element is not visible, but it maintains its position on the page.
Long-press of the folders/files to show hidden options. Tap on the menu icon and select Hide. This will hide the folder and all the files saved within. Now, when you open the music player app, you won't see these audio file formats with your songs.
The autoplay attribute is a boolean attribute. When present, the audio will automatically start playing as soon as it can do so without stopping. Note: Chromium browsers do not allow autoplay in most cases. However, muted autoplay is always allowed.
To embed audio in HTML, we use the <audio> tag.
I agree with the sentiment in the comments above — this can be pretty annoying. We can only hope you give the user the option to turn the music off.
However...
audio { display:none;}
<audio autoplay="true" src="https://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg">
The css hides the audio
element, and the autoplay="true"
plays it automatically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With