0

I want to implement a src location like this

 <audio src="D:/Js%20Project/audioPlayer/src/sanail.mp3" controls></audio>

but this is not working and I know that

<audio src="./src/sanail.mp3"></audio>

is working.

This is my source code and this is not working

<html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Audio Player</title>
    </head>

    <body>
      
        <audio src="D:/Js%20Project/audioPlayer/src/sanail.mp3" controls></audio>
    </body>

</html>
Carson
  • 6,105
  • 2
  • 37
  • 45

2 Answers2

1

It all depends on the structure of your project. But, I think this may work:

<audio src="../src/sanail.mp3"></audio>

Anyway, I recommend you check this: https://www.w3schools.com/html/html_filepaths.asp

note: If you want the page to be on the web, you can't use local files. All of the resources must be in a hosting (like github pages).

Sonya
  • 103
  • 2
  • 8
-1

A page can't just load any file from your computer. You should run something like live-server.

  1. Install node and npm.
  2. In the command line, enter npm install live-server -G
  3. Navigate to the folder where your project is and enter live-server

https://nodejs.org/en/download/

Edit: I realize now that if you're just opening the html file in your browser then you should be able to access local resources. Try it like this:

<audio src="file:///D:/Js%20Project/audioPlayer/src/sanail.mp3" controls></audio>

But it definitely won't work this way if you are using a http server like I suggested above.

Andrew
  • 214
  • 1
  • 6