我正在使用下面的代码来显示JPlayer,并且效果很好,但是我想知道是否可以添加类似于mp3,title或poster的变量来将URL添加到poster元素,使其可单击。
这样做的原因是目前正在使用JPlayer播放产品的样本,但是我希望张贴者随后链接回该产品。
jQuery(document).ready(e => {
jQuery("#jquery_jplayer_1").jPlayer({
swfPath: "https://cdnjs.cloudflare.com/ajax/libs/jplayer/2.9.2/jplayer/jquery.jplayer.swf",
supplied: "webmv, ogv, m4v, oga, mp3",
cssSelectorAncestor: "#jp_container_1",
useStateClassSkin: true,
autoBlur: false,
smoothPlayBar: true,
keyEnabled: true,
audioFullScreen: true
});
jQuery('a[data-mp3]').click(function(e) {
e.preventDefault();
jQuery("#jquery_jplayer_1").jPlayer("setMedia", {
mp3: jQuery(this).attr("data-mp3"),
title: jQuery(this).attr("data-title"),
poster: jQuery(this).attr("data-poster") }).jPlayer("play");
})
jQuery("#jp_container_1").hide();
jQuery("#jquery_jplayer_1").bind(jQuery.jPlayer.event.play, function() {
jQuery("#jp_container_1").show();
});
jQuery("#jquery_jplayer_1").bind(jQuery.jPlayer.event.ended, function() {
jQuery("#jp_container_1").hide();
});
});
</script>
<div id="jplayer">
<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>
</div>