dhanasekar
dhanasekar

Reputation: 1

Can't play audio files in localhost

here is my code to play audio file in localhost and got error as "Could not open location; you might not have permission to open the file." please help me Thnx in advance

<!DOCTYPE html>
<html>

<head>
    <center>
        <script language="JavaScript" type="text/javascript">
            function getPath() {
                playId.src = "/root/Desktop/103.mp3";
            }
        </script>
    </center>
</head>

<body>
    <input type="submit" value="PLAY PATH" onclick="getPath()" />
    <embed height="50" width="100" id="playId">
</body>

</html>

Upvotes: 0

Views: 1745

Answers (1)

Scimonster
Scimonster

Reputation: 33409

playId is not defined. You need to find the element, and then set the attribute.

document.getElementById('playId').src = "/root/Desktop/103.mp3";

Also, you probably need to set it to a local file:// URL if it isn't already.

Upvotes: 1

Related Questions