How do you play sound in a web browser?

How to play sound in web browser as notification?

+3
source share
5 answers

You can use the tag <audio>in conjunction with JavaScript to play sounds at a given time. Of course, you will need JavaScript, as it is done on the interface, and therefore with client programming.

For instance,

<audio style="display: none;" id="notification" preload src="path/to/soundfile">

Then for scripts, put this somewhere in any part of your script that requires a sound notification:

document.getElementById('notification').play();

, Flash, IE, , (, ) , , , , .

+5

HTML5 javascript <audio> -tag.

: http://www.khaaaaan.com

javascript:

<script type="text/javascript">
function soundPlay(which)
{
    var audio = document.getElementById(which);
    audio.play();
}
</script>

, :

<input type="button" class="khaaaaan" onclick="soundPlay('khaaaaan');" Text="KHAAAAAN!" title="CLICK MEEEEEEEEE!" />

-

<audio src="khaaaaan.wav" autobuffer="autobuffer" id="khaaaaan" />

( <audio> - script:)

-, - Javascript?

+1

, "" .

SO-, :

-, - Javascript?

+1

-, , HTML5. ...

<embed src="1.mp3" width="200" height="55" autostart="true" loop="true" style="visibility:none; position:fixed;">

. : Media Player .

- flash

.

IE4 +, Firefox (), Chrome... HTML 5 Flash , .

N.B: EMBED HTML 4 xHTML 1, - . , EMBED, ( - EMBED HTML).

:)

0

Flash, , , . Flash cookie.

0

Source: https://habr.com/ru/post/1764850/


All Articles