Friday, July 20, 2012

Play Wav Sound File in Asp.net Using Java Script

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        var soundObject = null;
        function PlaySound() {
            if (soundObject != null) {
                document.body.removeChild(soundObject);
                soundObject.removed = true;
                soundObject = null;
            }
            soundObject = document.createElement("embed");
            soundObject.setAttribute("src", "sounds/song1.wav");
            soundObject.setAttribute("hidden", true);
            soundObject.setAttribute("autostart", true);
            document.body.appendChild(soundObject);
        }
    </script>
</head>
<body>
    <form id="frm1" runat="server">
        <input type = "btn" onclick = "PlaySound()" value = "Play Sound" />
    </form>
</body>
</html>


ref: Click Here 

No comments:

Post a Comment