Audio play handler being called twice.

by Richard_Liu

HTML

<audio id="testClip" name="testClip" controls="" preload="auto">
<source src="http://hpr.dogphilosophy.net/test/opus.opus" type="audio/ogg; codecs=&quot;opus&quot;">
<source src="http://hpr.dogphilosophy.net/test/weba.weba">
<source src="http://hpr.dogphilosophy.net/test/ogg.ogg">
<source src="http://hpr.dogphilosophy.net/test/mp3.mp3">
<source src="http://hpr.dogphilosophy.net/test/wav.wav">
<source src="http://hpr.dogphilosophy.net/test/flac.flac">
Y'all's browser doesn't support the &lt;audio&gt; tag, so this test is pointless.  I recommend upgrading to the current version of <a href="http://getfirefox.com">Mozilla Firefox</a>,
although <a href="http://google.com/chrome">Google's Chrome browser</a> and <a href="http://opera.com">Opera</a> are also good.  
If you feel you MUST use Microsoft Internet Explorer, <a href="http://windows.microsoft.com/en-US/internet-explorer/downloads/ie-9/worldwide-languages">IE9</a> is the earliest version that supports &lt;audio&gt;.
</audio>

JavaScript

console.clear&&console.clear();
var $audio = $('audio'), audio = $audio[0];
$audio.on('play', function () {
    console.log('play');
}).on('pause', function () {
    console.log('pause');
});

setTimeout(function() {
    console.log('--trigger play & pause --');
    $audio.trigger('play');
}, 1000);
setTimeout(function() {
    $audio.trigger('pause').prop('currentTime', 0);
}, 2000);
setTimeout(function() {
    console.log('--native play & pause --');
    audio.play();
}, 3000);
setTimeout(function() {
    audio.pause();
}, 4000);