当变量大于一个数字时播放声音

PHP Play sound if a variable is over a number

本文关键字:一个 数字 播放声音 变量 大于      更新时间:2023-09-26

我想知道如果我的变量大于另一个,或大于一个数字,我怎么能播放声音。

我还需要声音与Internet Explorer兼容,并且该框是不可见的。

我已经尝试了很多事情,但一无所获。所以我请求你的帮助。

这是我使用的一个Javascript库,名为jPlayer,它是jQuery Javascript库的一个插件。

你可以用你的PHP脚本在你的页面中编写这一小段Javascript代码:

$(function() {
  $("#audio").jPlayer({ // Selector, in this case the player in not shown
    ready: function () {
      $(this).jPlayer("setMedia", {
        mp3: 'hellmarch.mp3'
      }).jPlayer('play'); // Play immediately
    },
    supplied: 'mp3',
    swfPath: ''
  });
});

此代码将立即播放名为hellmarch.mp3的音频文件。

如果你的等式结果为true,则回显html5音频标签并使其自动播放。比如

<audio controls autoplay="autoplay" style="display:none">
<source src="example.ogg" type="audio/ogg">
<source src="example.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>