我们正在使用JPlayer 2.9.2,它有一个非常基本的原型(参见下面的代码片段)。
当曲目结束时,暂停'事件被解雇然后结束了#39; Chrome中的事件,就像在Firefox中一样,只有'暂停'事件被解雇了。
任何人都可以解释为什么会这样吗?
我们加入了这个原型,因为在我们的生产代码中,我们看到了同样令人困惑的行为。比如“暂停”等。正在手机上开火并且已经结束了#39;正在桌面上开火。
<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,
ended : function(){
var sam = 1;
},
pause : function(){
var sam = 2;
},
});
});
</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>
&#13;
答案 0 :(得分:0)
我刚试过它,它对我有用。您使用的是哪个Firefox版本?
http://jsfiddle.net/chq6uu16/13/
源代码jPlayer:
mediaElement.addEventListener("ended", function () {
if (entity.gate) {
// Order of the next few commands are important. Change the time and then pause.
// Solves a bug in Firefox, where issuing pause 1st causes the media to play from the start. ie., The pause is ignored.
if (!$.jPlayer.browser.webkit) { // Chrome crashes if you do this in conjunction with a setMedia command in an ended event handler. ie., The playlist demo.
self.htmlElement.media.currentTime = 0; // Safari does not care about this command. ie., It works with or without this line. (Both Safari and Chrome are Webkit.)
}
self.htmlElement.media.pause(); // Pause otherwise a click on the progress bar will play from that point, when it shouldn't, since it stopped playback.
self._updateButtons(false);
self._getHtmlStatus(mediaElement, true); // With override true. Otherwise Chrome leaves progress at full.
self._updateInterface();
self._trigger($.jPlayer.event.ended);
}
}, false);
看起来首先被解雇的不同顺序是必要的浏览器修复。
此外,我已经多次听过'Miaow-07-Bubble',我现在非常喜欢它:P。