Hoping to have two buttons, one to "Pause" one to "Play" the MP3 audio file. Buttons show but do not pause/play the audio, Aswell as the audio does not play whatsoever. Here's my code I'm using. Thanks.
HTML
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Loadingscreen</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="script.js"></script>
</head>
<body>
<audio controls id="song">
<source src="audio/music.mp3" type="audio/mpeg">
</audio>
<button onclick="playAudio()" type="button">Play</button>
<button onclick="pauseAudio()" type="button">Pause</button>
<div class="slides slowFade">
<div class="slide">
<img src="img/image1.jpg" alt="img"/ height="100%" width="100px">
</div>
<div class="slide">
<img src="img/image2.jpg" alt="img"/ height="100%" width="100px">
</div>
<div class="slide">
<img src="img/image3.png" alt="img"/ height="100%" width="100px">
</div>
<div class="slide">
<img src="img/image4.jpg" alt="img"/ height="100%" width="100px">
</div>
</div>
</body>
</html>
JavaScript
var x = document.getElementById("song");
function playAudio() {
x.play();
}
function pauseAudio() {
x.pause();
}
html
folder with css file, js file. So should be /html/music.mp3 correct?html/music.mp3
andmusic.mp3
still haven't gotten it to play with the buttons.console
tab. Is there any error there?