• Hi –

    Good plugin so far. How can I embed the player in a php template? I tried the following, which has worked for including shortcode for other plugins in template files:

    <?php echo do_shortcode('[mp3-jplayer tracks="FEED:LIB"]') ?>

    But no dice. The words “Next” “Play” etc show up, and nothing else, no player.

    Adding the shortcode [mp3-jplayer tracks="FEED:LIB"] to a new Page works perfectly, but I want to include it in a template so it’s entirely automated. Can anyone help with this?

    Thanks,
    Jeremy

    https://www.ads-software.com/extend/plugins/mp3-jplayer/

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter earthtojeremy

    (@earthtojeremy)

    I’m either looking for a way to get the do_shortcode to work, or preferably something like <?php get_jplayer(); ?> or whatever this plugin uses (not sure why the docs make no mention of this as it must be commonly desired usage.)

    Thanks.

    Thread Starter earthtojeremy

    (@earthtojeremy)

    As a work-around, I made a Page with the player shortcode, then called this page up in the sidebar. It’s still broken, showing nothing but text for the player nav.

    However, when I view the Page where I inserted the player, the player appears in the sidebar and functions perfectly. Just not on any other page. After viewing the source I realized what was wrong – for some reason, when the player is loaded in the sidebar (which is loaded by the template from sidebar.php), it doesn’t add the necessary script code in the wp_header region. But when the player is loaded in the body content of the page, it loads the script in the header correctly, which is why the player in the sidebar works on this page.

    Anyone know how to make it call up the script in the header like it’s supposed to when the player is embedded in the sidebar?

    Thanks.

    There is a template tag help file, but it’s somewhat hidden away.

    Click Settings / MP3 JPlayer / Show Help / Template Tag Help

    Basically you need to put this in your header:
    <?php mp3j_addscripts(); ?>

    And something like this where the player should appear:
    <?php mp3j_put( '[mp3-jplayer tracks="FEED:LIB" pick="5"]' ); ?>

    Thread Starter earthtojeremy

    (@earthtojeremy)

    Holy crap, you rule. I just spent the whole day looking for any mp3 playlist plugin that works (surprise, almost all of them are broken or full of plugin conflicts!) At one point I tried manually adding the scripts for this plugin in the header, but no go. Not sure why the “show help” button needed to be so barely visible, would have saved me and I’m sure many others hours of wasted work.

    Thanks a lot, thoughton, you saved the day.

    No problem ?? although you may have noticed the thread I started a few minutes ago saying that the player inserted in this way seems to be invisible in Chrome and Safari in some cases ??

    Thread Starter earthtojeremy

    (@earthtojeremy)

    It works perfectly in the latest Chrome/Firefox/Safari/IE for me. If you want I can PM you the site I’m developing and you can root around the code, if you think it might help.

    Sure, thanks for the offer, I’ll take any suggestions at this point. ??

    It’s working fine in all browsers for me if I insert it in page.php, but in sidebar.php it’s invisible in Chrome and Safari. Very odd.

    Thread Starter earthtojeremy

    (@earthtojeremy)

    I actually don’t know how to send private messages on this site, I’ve never tried. Is that even an option? If so you can also send me the code in your header.php and sidebar.php and I can take a look.

    Now that I’ve looked into it I don’t think this site has any PM function, whoops.

    Thanks muchly for the offer, but I don’t see how my header.php can be the problem since the template tags work in page.php. And my sidebar.php is basically the stock twenty-ten sidebar. The only thing I’ve added is the navigation div from the twenty-ten header, and another div containing the template tag code.

    I guess it’s some kind of Webkit problem. I am experimenting with an ugly hack to insert the player in page.php and move it over to the sidebar with absolute positioning. Ugh. ??

    Thread Starter earthtojeremy

    (@earthtojeremy)

    Yeah considering I cut my site templates from the original core twentyten framework, I’m not sure what it could be. I have a ton of plugins installed too, and no conflicts. At any rate I’d still be willing to take a look, it’s worth a shot and if I can’t help, someone else probably can. I guess just post the whole code from header.php, page.php, and sidebar.php here (separate them and use the “code” wrap button so it’s readable.) Absolute positioning the player across the screen is almost certainly not going to work right, at least not across all browsers/screen resolutions.

    I guess just post the whole code from header.php, page.php, and sidebar.php here

    No, thank you. all of the code will be immediately removed. Please see the Forum Rules.

    Thanks for the offer Jeremy, I needed to get this done like yesterday so I’ve gone with the ugly hack. Works in all the major browsers including IE7-10. Not Opera but oh well ??

    Hey Guys,
    I just installed the player and tried something similar, after a few attempts i just went ahead and installed the “Widgets on Pages” plugin, then just dragged the jplayer widget to the widget i created. In my template I added <?php widgets_on_template(“you widget name”); ?> so my new side bar could be created anywhere in the template and it worked perfectly. Try this as an alternative, as for just that short-code in the php, i dont know why it’s not working, maybe because the plugin might be failing to load the the js script it loads in the footer?? :~}

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘[Plugin: MP3-jPlayer] How to embed player in php template?’ is closed to new replies.