JavaScript 简单的音乐播放


// Closing current script section to add elements

// Closing current script section to add elements
</script>

<audio id="LM_Audio" style="display: none;"></audio>
 
<script type="text/javascript"> // Starting new script section after adding elements
$(function() {
    var AudioTable = [
     { address:"0/0/95", url:"/scada/resources/img/click.mp3"},
     { address:"0/0/96", url:"/scada/resources/img/alarm.mp3" },
     { address:"32/2/2", url:"/user/audio3.mp3" },
   ];
  for (var i in AudioTable) {
    CreateListeners(AudioTable[i].address,AudioTable[i].url);
  }
  function CreateListeners(groupaddr,url){
    // Make event listener to object
    if (typeof grp != 'undefined') {
      grp.listen(groupaddr, function(object, state) {
        var value = object.value; 
        if (state == 'value') {
          mute = Scada.encodeGroupAddress(groupaddr); // Use bit object !
          var LM_snd = document.getElementById("LM_Audio");
    			LM_snd.src= url;	
    			LM_snd.load();
          objectStore.addListener(mute, function(obj, type) {
          if(obj.value == 1){
            LM_snd.play();
        		LM_snd.muted = false;
    			} else {
     		 			LM_snd.muted = true;
    			}
 	 		});
        }
      }, true);
    }
    }
});

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值