Hi so I have been developing an audio player app with HTML and JavaScript. I'm trying to embed an audio tag inside of my html file, following the tutorial from here.
And I have followed it till 5:00, and inside the audioPlayer div, it should've shown the audio element we have embedded using the JS. Like this from the video:
But in my case the div tag won't expand. Means the audio tag is not embedded right?
And show an error like the following:
These are my codes:
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale-1.0">
<title>Javascript Audio Player</title>
</head>
<body>
<div class="audioPlayer"></div>
<script src="../static/common-js/player.js"></script>
</body>
</html>
player.js:
import AudioPlayer from './audioPlayer';
const audioPlayer = new AudioPlayer('./audioPlayer', [
{url: '../music/rainfall.mp3', name: 'Alleviating Rainfall'},
]);
AudioPlayer.js:
export default class AudioPlayer {
constructor(selector = '.audioPlayer', audio = []) {
this.playerElem = document.querySelector(selector);
this.audio = audio;
this.currentAudio = null;
this.createPlayerElements();
}
}
and here is my file directory:
I just want to know where did I go wrong. Thank you in advance! I'd appreciate every help.