Click here to Skip to main content
15,920,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
ASP.NET
 <head runat="server">
    <title></title>
    <script>
        function PlaySound(soundobj) {

            var thissound = document.getElementById(soundobj);

            thissound.play();

        }


        function PauseSound(soundobj) {

            var thissound = document.getElementById(soundobj);

            thissound.pause();

        }


</script>
</head>
<body>
    <audio id="audio1" src="Sounds/DPM317.wav" controls="controls" preload="auto"></audio>

    <audio id="audio2" src="Sounds/DS250069new.wav" controls="controls" preload="auto"></audio>

    <form id="form1" runat="server">
    <div>
     <input type="button" value="PlaySound" onclick="PlaySound('audio1'), PlaySound('audio2')" />

     <input type="button" value="PauseSound" onclick="PauseSound('audio2'), PauseSound('audio1')" />
    </div>
    </form>
</body>

Above is my complete code which is used to play .wav files in chrome browser but when debugging in developer tools i am seeing the error near
HTML
<input type="button" value="PlaySound" onclick="PlaySound('audio1'), PlaySound('audio2')" />
<input type="button" value="PauseSound" onclick="PauseSound('audio2'), PauseSound('audio1')" />
and thissound.play(); and thissound.pause(); how can i solve this?

What I have tried:

I tried the above code but it gives me errors
Posted
Updated 27-Oct-16 3:41am
v3
Comments
ZurdoDev 27-Oct-16 15:26pm    
Can you post the full exception?
Karthik_Mahalingam 28-Oct-16 8:04am    
what is the error message?

1 solution

HI,

have a look on this example. It works without error.
A Pen by xszaboj[^]

I think your problem could be that your path is not correct to either first or second wav file.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900