gpt4 book ai didi

javascript - jplayer 绑定(bind)似乎不起作用

转载 作者:行者123 更新时间:2023-12-01 05:21:14 24 4
gpt4 key购买 nike

我继承了一个使用 jPlayer 的网络播放器。它对于播放音频文件效果很好,但我试图在用户播放轨道时设置一些隐藏字段,但我似乎无法在 jPlayer 中获得绑定(bind)到任何事件的内容。我已经使用类似的代码绑定(bind)到 h1 标签上的单击事件,它工作正常,但 jplayer 却不行。也没有错误。我从 jPlayer 的文档中获取了绑定(bind)示例。 这是我正在尝试做的事情的片段:

 $(document).ready(function () {

//listener for playing the file
$("#jquery_jplayer_1").bind($.jPlayer.event.play, function (event) {

alert('play');
});
});

这是我的 html:

 <div id="jquery_jplayer_1" class="jp-jplayer"></div>

<div id="jp_container_1" class="jp-audio" >
<div class="jp-type-single">
<div id="htmlPlayer" style="display: none">
<audio id="audioPlayer" controls style="width:100%;">
<source id="mp3Source" type="audio/mp3" />
</audio>
</div>
<div class="htmlHidePoint" style="display: none">
<div class="jp-gui jp-interface">
<ul class="jp-controls">
<li><a href="javascript:;" onclick="javascript:alert('test');" class="jp-play" tabindex="1">play</a></li>
<li><a href="javascript:;" class="jp-pause" tabindex="1">pause</a></li>
<li><a href="javascript:;" class="jp-stop" tabindex="1">stop</a></li>
<li><a href="javascript:;" class="jp-mute" tabindex="1" title="mute">mute</a></li>
<li><a href="javascript:;" class="jp-unmute" tabindex="1" title="unmute">unmute</a></li>
<li><a href="javascript:;" class="jp-volume-max" tabindex="1" title="max volume">max volume</a></li>
</ul>
<div class="jp-progress">
<div class="jp-seek-bar">
<div class="jp-play-bar"></div>
</div>
</div>
<div class="jp-volume-bar">
<div class="jp-volume-bar-value"></div>
</div>
<div class="jp-time-holder">
<div class="jp-current-time"></div>
<div class="jp-duration"></div>

<ul class="jp-toggles">
<li><a href="javascript:;" class="jp-repeat" tabindex="1" title="repeat">repeat</a></li>
<li><a href="javascript:;" class="jp-repeat-off" tabindex="1" title="repeat off">repeat off</a></li>
</ul>
</div>
</div>
</div>
<div class="jp-title">
<ul>
<li><span id="songname">No Song Selected</span></li>
</ul>
<div class="under">
<ul>
<li><a href="#" onclick="ViewTranscript();return false;" onkeypress="ViewTranscript();return false;" tabindex="2">Transcript</a></li>
<li><a href="#" onclick="ViewDowloadOptions();return false;" onkeypress="ViewDowloadOptions();return false;" tabindex="2">Download</a></li>
</ul>
</div>
</div>
<div class="htmlHidePoint" style="display: none">
<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>&nbsp;



实际的源文件是通过 jPlayer 方法中的错误选项加载的:

               error: function (event) {
if (event.jPlayer.error.type == 'e_url_not_set') {
$(this).jPlayer("setMedia", {
mp3: '<%=ResolveUrl("~/Handlers/Podcasts.ashx") %>?command=ZipPodcast&PodcastID=' + selectedPodcast.ItemID + '&options=audio'
});

$(this).jPlayer("play");
}
},

最佳答案

显示 jPlayer 的 html。确保 ID 正确。

尝试在选项上指定它:

$("#jquery_jplayer_1").jPlayer({
play: function() {
alert('hi');
}
});

您是在 jPlayer 使用您的选项初始化之前还是之后进行绑定(bind)?

绑定(bind)时jPlayer是否在页面上?

关于javascript - jplayer 绑定(bind)似乎不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43501198/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com