1
我们使用的是JPlayer 2.9.2和一个非常基本的原型(请参阅下面的代码片段)。为什么jPlayer在轨道播放结束时触发暂停事件
当轨道结束时,在Chrome中触发'pause'事件,然后触发'ended'事件,在Firefox中,只有'pause'事件被触发。
任何人都可以解释为什么这种情况?
我们刺激了这个原型,因为在我们的生产代码中,我们看到了类似混淆的行为。如'暂停'在手机上发射,'结束'在台式机上发射。
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jplayer/2.9.2/jplayer/jquery.jplayer.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#jquery_jplayer_1").jPlayer({
ready: function() {
$(this).jPlayer("setMedia", {
title: "Bubble",
m4a: "http://www.jplayer.org/audio/m4a/Miaow-07-Bubble.m4a",
oga: "http://www.jplayer.org/audio/ogg/Miaow-07-Bubble.ogg"
});
},
cssSelectorAncestor: "#jp_container_1",
swfPath: "/js",
supplied: "m4a, oga",
useStateClassSkin: true,
autoBlur: false,
smoothPlayBar: true,
keyEnabled: true,
remainingDuration: true,
toggleDuration: true,
\t \t ended : function(){
\t \t \t var sam = 1;
\t \t },
\t \t pause : function(){
\t \t \t var sam = 2;
\t \t },
\t \t
});
});
</script>
</head>
<body>
<div id="jquery_jplayer_1" class="jp-jplayer"></div>
<div id="jp_container_1" class="jp-audio" role="application" aria-label="media player">
<div class="jp-type-single">
<div class="jp-gui jp-interface">
<div class="jp-volume-controls">
<button class="jp-mute" role="button" tabindex="0">mute</button>
<button class="jp-volume-max" role="button" tabindex="0">max volume</button>
<div class="jp-volume-bar">
<div class="jp-volume-bar-value"></div>
</div>
</div>
<div class="jp-controls-holder">
<div class="jp-controls">
<button class="jp-play" role="button" tabindex="0">play</button>
<button class="jp-stop" role="button" tabindex="0">stop</button>
</div>
<div class="jp-progress">
<div class="jp-seek-bar">
<div class="jp-play-bar"></div>
</div>
</div>
<div class="jp-current-time" role="timer" aria-label="time"> </div>
<div class="jp-duration" role="timer" aria-label="duration"> </div>
<div class="jp-toggles">
<button class="jp-repeat" role="button" tabindex="0">repeat</button>
</div>
</div>
</div>
<div class="jp-details">
<div class="jp-title" aria-label="title"> </div>
</div>
<div class="jp-no-solution">
<span>Update Required</span>
To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>.
</div>
</div>
</div>
</body>
嗨丹。你有没有想过这个? –
不,我在GitHub上也发现了一个bug。思考? – Dan
不是我的头顶。根据源代码,FireFox也应该解雇'Ended'。我会在有空的时候再测试它。你能链接github链接吗? 暂停事件被触发,因为否则点击进度条将从该点播放,当它不应该时,因为它停止播放(取自src代码中的注释)。所以这应该发生。 –