HTML: Start-/Stop-Button für eine mp3-Datei?
Moin,
ich würde gerne meine drei HTML-Buttons mit den Sounds "null", "eins" und "zwei" so umfunktionieren, sodass sie beim zweiten Mal daraufklicken den Sound aufhören zu spielen. Also beim ersten Mal klicken Start und beim zweiten Mal klicken Sound-Stop.
Es wäre cool, wenn Ihr das direkt in mein Skript schreiben würdet. 😀
MfG
Tim
<!DOCTYPE html>
<html>
<head>
<style>
nav#nav1 {
margin-top: 48px;
}
nav#nav1 > a {
background: #B9E1FF;
color: #000;
padding: 20px;
text-decoration: none;
border-radius: 10px;
font-family: "Arial Black", Gadget, sans-serif;
}
nav#nav1 > a:hover {
background: #BBEA00;
}
nav#nav1 > a:active {
background: #EEFFA8;
}
</style>
<script>
var null = new Audio();
null.src = 'null.mp3';
</script>
<script>
var eins = new Audio();
eins.src = 'eins.mp3';
</script>
<script>
var zwei = new Audio();
zwei.src = 'zwei.mp3';
</script>
</head>
<body>
<nav id="nav1">
<a href="#" onmousedown="null.play()">Sound 0</a>
<a href="#" onmousedown="eins.play()">Sound 1</a>
<a href="#" onmousedown="zwei.play()">Sound 2</a>
</nav>
</script>
</body>
</html>