0

我想制作一个由添加到 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
});
4

1 回答 1

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
});

    });
于 2013-10-10T11:20:47.480 回答