Why won't my HTML5 audio channel?

The site is on the page http://ajf.me/stuff/eva at the time of writing. Source:

<!DOCTYPE html>
<html style="height: 100%;">
<head>
<title>eva</title>
</head>
<body style="background-color: black; background-image: url('eva.png'); background-repeat: no-repeat; background-position: center center; height: 100%; margin: 0px; padding: 0px;">
<audio autoplay loop>
    <source src="eva.mp3" type="audio/mpeg" />
    <source src="eva.ogg" type="audio/ogg" />
    <source src="eva.wav" type="audio/wav" />
</audio>
</body>
</html>

Sound plays nicely in Chrome, IE9, and Firefox, but it doesn't have a loop. The sound file cannot be distorted since it was created by Audacity. Is there any other explanation why it does not go in cycles?

+2
source share
2 answers

You can just do it

<audio autoplay loop>

Attributes should not have anything else.


EDIT

According to this, Firefox does not like it loop. He offers a js solution:

document.getElementById('audio_2').addEventListener('ended', function(){
    this.currentTime = 0;
}, false);

http://forestmist.org/2010/04/html5-audio-loops/


EDIT

HTML5 audio loop firefox. 26.0 (, )

+9

Firefox . , Firefox, , . , :

if (typeof new Audio().loop == 'boolean')

true, . false, . javascript, id if .

if !(typeof new Audio().loop == 'boolean') {
    audioToLoop = document.getElementById('audio_id_here');
    audioToLoop.addEventListener('ended', function () {
        this.currentTime = 0;
        this.play();
    }, false);
}

.

+8

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


All Articles