Barra de progreso de audio
Publicado por Jean (22 intervenciones) el 17/12/2020 15:52:53
Hola, tengo este reproductor de audio, pero no tengo claro como hacer que la barra de funciones avance, algun consejo??
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE HTML>
<HEAD>
<script>
function reproducir()
{
var boton=document.getElementById("reproducir")
addEventListener("click",presionar,false)
}
function presionar()
{
var audio=document.getElementById("audio")
if(!audio.paused && !audio.ended)
{
audio.pause()
reproducir.innerHTML="Reproducir"
window,clearInterval(bucle)
}
else
{
audio.play()
reproducir.innerHTML="Pausa"
var bucle=setInterval(estado, 1000)
}
}
function menos5sg()
{
var audio=document.getElementById("audio")
audio.play()
audio.currentTime=audio.currentTime-5
}
function mas5sg()
{
var audio=document.getElementById("audio")
audio.currentTime=audio.currentTime+5
audio.play()
}
function restar()
{
var audio=document.getElementById("audio")
audio.currentTime=0
audio.play()
}
function iniciar()
{
var elemento = document.getElementById("lienzo");
var lienzo = elemento.getContext("2d");
lienzo.strokeRect(0,0,500,50)
var audio=document.getElementById("audio")
var posicion = (audio.currentTime/audio.Duration)*20
lienzo.fillRect(0,0,5,50)
}
window.addEventListener("load", iniciar, false)
</script>
</HEAD>
<BODY>
<canvas id="lienzo" height="50" width="500"></canvas>
<section id="reproductor">
<audio id="audio">
<source src="MagicalDream.mp3">
<source src="MagicalDream.ogg">
</audio>
<button id="reproducir" onclick="reproducir()">Reproducir/Pausar</button>
<button id="-5sg" onclick="menos5sg()">-5sg</button>
<button id="+5sg" onclick="mas5sg()">+5sg</button>
<button id="0" onclick="restar()">Restar</button>
</section>
</BODY>
Valora esta pregunta


1