js播放wav文件(源码)

用js播放.wav文件

复制代码 代码如下:


<html>
<head>
<script language="javascript">
function playSound(id)
{
var node=document.getElementById(id);
if(node!=null)
{
node.Play();
}
}
</script>
</head>
<body>
<embed src="https://www.jb51.net/music.wav" type="audio/x-wav" hidden="true" autostart="false" loop="false"/><a 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 src='https://www.jb51.net/music.wav' loop=false autostart=false hidden=true><a href='#' onclick=https://www.jb51.net/article/\"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=https://www.jb51.net/article/\"player\" TYPE=https://www.jb51.net/article/\"application/x-mplayer2\" src=https://www.jb51.net/article/\"../wav/" + num + ".wav\" loop=https://www.jb51.net/article/\"false\" autostart=https://www.jb51.net/article/\"true\" hidden=https://www.jb51.net/article/\"true\"></embed>";
}
</script>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wdgxwy.html