jQuery("#jquery_jplayer_1").jPlayer({
    ready: function () {
        jQuery(this).jPlayer("setMedia", {
        mp3: "/wp-content/themes/casaluna/music/01_Yari.mp3",
        oga: "/wp-content/themes/casaluna/music/01_Yari.ogg"
        }).jPlayer("play");
        [...]


嗨,在事件“播放”被触发的地方,我想添加一个对函数的引用。
(它将检查是否在主页上)

在何处以及如何拆分此段以添加新功能?

最佳答案

根据documentation,您可以将处理程序附加到播放事件,如下所示:

$("#jquery_jplayer_1").bind($.jPlayer.event.play, function(event) { // Add a listener to report the time play began
  // Get the pathname and homepage values in a manner suitable to your
  // application before the following check.
  if ( pathname != homepage ) {
      return false;
  }
});


如果需要取消绑定功能,可以这样进行:

$("#jquery_jplayer_1").unbind($.jPlayer.event.play); // Remove all play event listeners


您可以将此代码插入jQuery onload函数($(function() {...});)中的任何位置以附加处理程序。

关于jquery - jplayer和jquery,添加一个函数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6455173/

10-12 00:05