js播放wav文件(源码)

时间:2021-05-26

用js播放.wav文件
复制代码 代码如下:
<html>
<head>
<script language="javascript">
function playSound(id)
{
var node=document.getElementById(id);
if(node!=null)
{
node.Play();
}
}
</script>
</head>
<body>
<embed name="3_devUnknown" id="3_devUnknown" src="music.wav" type="audio/x-wav" hidden="true" autostart="false" loop="false"/><a onclick="javascript:playSound('3_devUnknown')" href="#">music.wav</embed/>
</body>
</hmtl>
var recordhisStore = new Ext.data.JsonStore({
root: 'dataRoot',
totalProperty: 'totalCount',
idProperty: 'threadid',
remoteSort: true,
fields: [
{name: 'id', type: 'string'},
{name: 'src', type: 'string'},
{name: 'dst', type: 'string'},
{name: 'srcip', type: 'string'},
{name: 'dstip', type: 'string'},
{name: 'begin_date', type: 'date', dateFormat:'Y-m-d H:i:s'},//onclick='javascript:startwav(\" "+ value +" \")'
{name: 'end_date', type: 'date', dateFormat:'Y-m-d H:i:s'},
{name: 'content', type: 'string', convert:function(value,rec){
return "<embed id='"+ rec.id +"_devUnknown' name='"+ rec.id +"_devUnknown' src='music.wav' loop=false autostart=false hidden=true><a href='#' onclick=\"javascript:playSound('"+rec.id+"_devUnknown')\">"+value+"</a></embed>";
}}
],
proxy: new Ext.data.HttpProxy({
url: 'ctl.php?c=HisRecordQueryController&a=Query'
}),
sortInfo: {field: 'begin_date', direction: 'ASC'},
listeners:{
beforeload:function(obj,params){
var begin_date = document.getElementById("his_startdt").value;
var end_date = document.getElementById("his_enddt").value;
var src = document.getElementById("his_src").value;
var dst = document.getElementById("his_dst").value;
recordhisStore.baseParams = {limit:params.params.limit,start:params.params.start,begindate:begin_date,enddate:end_date,src:src,dst:dst};
}
}
});

js播放wav文件
复制代码 代码如下:
使用js,每隔1s播放对应的wav文件
<script language="javascript">
var arr = new Array();
var c = 0;
window.onload = function () {
var value1 = '<%=tel_2 %>';
var value2 = '<%=je %>'
StrToArray(value1);
StrToArray(value2);
}
var StrToArray = function (str) {
for (var i = 0; i < str.length; i++) {
arr[arr.length] = str.charAt(i);
}
}
var id = window.setInterval(function () {
if (c > arr.length) {
window.clearInterval(id); //清除
return;
}
embed(arr[c++]);
}, 1000);
var embed = function (num) {
if (num == "" || typeof num == "undefined") return;
document.getElementById("embed").innerHTML = "<embed name=\"player\" TYPE=\"application/x-mplayer2\" src=\"../wav/" + num + ".wav\" loop=\"false\" autostart=\"true\" hidden=\"true\"></embed>";
}
</script>

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章