0

I want to make a playlist made of files added to a Wordpress custom meta box. jPlayer generates the list using javascript, is there any way to bypass this and use regular html?

Edit:

Or could I get some guidance on how to call a wp function into the playlist? I am getting some ideas from call-php-function-from-jquery, but I am not sure how I would create multiple items/tracks or loop through them in the jquery script?

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
});
Community
  • 1
  • 1
Brownrice
  • 481
  • 6
  • 21

1 Answers1

1

Update:

I am now echoing my post_mime_types as '$alltracks' into the jquery script Like this:

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

    });
Brownrice
  • 481
  • 6
  • 21