将Jwplayer与Wordpress集成

时间:2013-10-07 16:53:10

标签: wordpress jplayer

我想制作一个由添加到Wordpress自定义元框中的文件组成的播放列表。 jPlayer使用javascript生成列表,有没有办法绕过这个并使用常规的html?

编辑:

或者我可以获得一些关于如何将wp函数调用到播放列表的指导?我从call-php-function-from-jquery得到了一些想法,但我不确定如何在jquery脚本中创建多个项目/轨道或循环它们?

new jPlayerPlaylist({
    jPlayer: "#jquery_jplayer_2",
    cssSelectorAncestor: "#jp_container_2"
}, [
    {
        title:"1",
        mp3:"url/file",
        oga:"url/file"
    },
    {
        title:"2",
        mp3:"url/file",
        oga:"url/file"
    },
], {
    swfPath: "js",
    supplied: "oga, mp3",
    wmode: "window",
    smoothPlayBar: true,
    keyEnabled: true
});

1 个答案:

答案 0 :(得分:1)

更新

我现在将我的post_mime_types作为'$ alltracks'回显到jquery脚本中,如下所示:

        <?php
    $query_audio_args = array(
           'post_type' => 'attachment',
           'post_mime_type' =>'application/ogg',
      );


      $audio_attachments = get_posts($query_audio_args);
            foreach ( $audio_attachments as $audio_attachment ) {

                $ogg = wp_get_attachment_url( $audio_attachment->ID );
                $tracks[] = '{
                    title:"'.$audio_attachment->post_title.'",
                    oga:"'.$ogg.'",
                }';
                $alltracks = implode(',',$tracks);
            }
    ?>

        $(document).ready(function() {

    new jPlayerPlaylist({
    jPlayer: "#jquery_jplayer_2",
    cssSelectorAncestor: "#jp_container_2"
}, [
    <?php echo $alltracks; ?>       
], {
    swfPath: "js",
    supplied: "oga, mp3,aif",
    wmode: "window",
    smoothPlayBar: true,
    keyEnabled: true
});

    });