استفاده از جاوا اسکریپت در فایل های صوتی WAV با ASP.Net
با سلام در این مقاله کوتاه با کد زیر برای پخش فایل های صوتی WAV با استفاده از جاوا اسکریپت در ASP.Net استفاده میکنیم .
<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/sound.wav");
soundObject.setAttribute("hidden", true);
soundObject.setAttribute("autostart", true);
document.body.appendChild(soundObject);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<input type = "button" onclick = "PlaySound()" value = "Play Sound" />
</form>
</body>
</html>
در بالا دکمه ورودی HTML که عملکرد جاوا اسکریپت PlaySoundرا در مسیر مشخص شده دانلود می کند قرار داده و سپس فایل WAV را پخش می کند.