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代碼中的註釋)。所以這應該發生。 –