0

我正在使用 jPlayer 播放列表,需要帮助来添加 Google Analytic 事件以显示已播放的歌曲,方法是按下播放按钮、单击播放列表中的标题、下一首或上一首,或者在歌曲末尾前进。我已尝试按 API 参考中所述的 ID 引用播放器,但我的控制台日志未显示。需要明确的是,我已经清理了这段代码,不显示我的真实标题和 URL

$(document).ready(function(){

var myPlaylist = new jPlayerPlaylist({
    jPlayer: "#jquery_jplayer_1",
    cssSelectorAncestor: "#jp_container_1"
}, [
    {
        title:"<Title Here>",

                    m4v: "<Link Here>",
        poster:" <Link Here> "
    },
           { 
        title:"<Title Here>",

                    m4v: " <Link Here> ",
        poster:" <Link Here> "
    },
    {
        title:" <Title Here> ",
        m4v: " <Link Here> ",
        poster: " <Link Here> "
    }
], {
    swfPath: "js",
                                 solution:"flash, html",
    supplied: "m4v "
});

$("#jquery_jplayer_1").jPlayer({
    ready: function() {
        console.log('here');
    },
    ended: function() {
        console.log('here');
    }
});
});

任何帮助表示赞赏。

4

1 回答 1

1

事件处理程序应与“swfPath”等一起在 jPlayerPlaylist 构造函数的第三个参数中提供。因此,在您的示例中,以下内容应该有效(我已将播放列表参数重构为一个单独的变量以稍微整理代码):

$(document).ready(function() {
  var playlist = [
    {title: "<Title Here>", m4v: "<Link Here>", poster: "<Link Here>"},
    {title: "<Title Here>", m4v: "<Link Here>", poster: "<Link Here>"},
    {title: "<Title Here>", m4v: "<Link Here>", poster: "<Link Here>"}
  ];

  var myPlaylist = new jPlayerPlaylist({
    jPlayer: "#jquery_jplayer_1",
    cssSelectorAncestor: "#jp_container_1"
  }, playlist, {
    swfPath: "js",
    solution:"flash, html",
    supplied: "m4v",
    ready: function() {
      console.log('here');
    },
    ended: function() {
      console.log('here');
    }
  });
});
于 2012-10-21T06:18:32.797 回答