i have this code:
<b>Title</b>: <span id='songTitle'></span><br>
<b>Album</b>: <span id='songAlbum'></span><br>
<script>
var songs =
[
{ filename: "title1.mp3", title: "title1", album: "Album1" },
{ filename: "title2.mp3", title: "title2", album: "Album2" },
// add more songs here...
];
var randomIndex = Math.floor(Math.random() * songs.length);
var song = songs[randomIndex];
document.querySelector("source").src = song.filename;
document.getElementById("songTitle").textContent = song.title;
document.getElementById("songAlbum").textContent = song.album;
</script>
<audio class="audio-element" controls="true" preload="none">
<!-- Adding audio sources -->
<source src="mp3file.mp3" type="audio/mpeg" />
<br>
<b>Your outdated browser does not support HTML5. <br>
Get Mozilla Firefox <a href="https://www.mozilla.org/pl/firefox/new/"> >HERE< </a></b>
</audio>
I want it to show Title and Album text randomly generated from the list, but it doesn't work :( There are just blank spaces, nothing written after the ":" mark, there should be "title1" and "Album1" for example.
Could anyone tell me what's wrong?