WordPress.org

Ready to get started?Download WordPress

Forums

MP3-jPlayer
Mp3-JPlayer with WP E-Commerce (4 posts)

  1. freshlinx
    Member
    Posted 2 years ago #

    Hi

    I am trying to use MP3-JPlayer on an online record shop website that I am building using WP E-Commerce plugin. I have managed to get the individual player and widget to work on single pages using shortcode in product description field and custom fields (meta fields) on post respectively. My problem is that I have each album as a product category and therefore each track on the album is listed on a product category page (which is classed as an archive page). Problem is that I can get neither a the widget to work (there are no custom fields as this is not a single post page even though I can retrieve the meta info for each track) but also the shortcodes will not work either as the page is not a single post but a category page generated by the wpsc products page template.

    Do you have any advice as to how I can get the plugin to detect info from this type of page please as I am tearing my hair out! Any advice would be very welcome!

    Thanks

    http://wordpress.org/extend/plugins/mp3-jplayer/

  2. buddy123
    Member
    Posted 1 year ago #

    I have the same issue. Jplayer works on individual product pages but not in a category list. Did you manage to resolve this issue?

  3. rawdolphe
    Member
    Posted 1 year ago #

    Gentlemen, show us your sites please.

    Thank you

  4. zigmas
    Member
    Posted 1 year ago #

    Hi! I had the same problem and I managed to make a lot of workarounds using the shortcodes and... Sort of hack php methods.

    I'm no programmer, so everything I'm going to put here has been done for the sake of my projects. So if it breaks up the css or things on your page, I warned you ;).

    So, the first thing I did was to add in my theme header the mp3j_addscripts() function. You have to find the <?php wp_head(); ?>
    tag in it and just before that line put <?php mp3j_addscripts() ?>

    so you can add any mp3-jplayer shortcodes on your theme.

    Second, In your theme category.php check up where you want to put your list, and modify this code to make it fit your needs

    <div id="yourcssid">
        <h1 style="border-bottom: 1px solid #000;">Player</h1>
        <div class="mp3j-popout-MIO" onclick="return launch_mp3j_popout('http://radio.struments.com/wp-content/plugins/mp3-jplayer/popout-mp3j.php',0);" style="visibility: visible;"></div>
        <div class="clear"></div>
    	<?php
        $args = array(
           'post_per_page' => 99, // An arbitrary number. Set high enough to be sure to get 5 posts with attachments
           'caller_get_posts' => 1, // Ignore stickies
           'category_name' => single_cat_title("", false),
        );
        $myquery = new WP_Query($args);
        if ($myquery->have_posts()) {
           $postcount = 1;
           while ($myquery->have_posts()) {
              $myquery->the_post();
              if ($postcount > 99) break;
              $attachment_args = array(
                 'post_type' => 'attachment',
    			 'post_mime_type' => 'audio',
                 'numberposts' => -1,
                 'post_status' => null,
                 'post_parent' => $post->ID
              );
    		  if (!empty($mp3s));
              $attachments = get_posts($attachment_args);
              if ($attachments) {
                 ++$postcount;
                 foreach ($attachments as $attachment) { ?>
    				<center><object width='10%' id='single<?php echo $mp3->ID; ?>' name='single<?php echo $mp3->ID; ?>'>
                    	<?php $url= $attachment->guid; ?>
                        <?php $titl = $attachment->post_title; ?>
                      	<?php  $cont = $attachment->post_content; ?>
                    	<?php echo mp3j_put( '[mp3j track="'.$titl.'@'.$url.'" captions="'.$cont.'"]' ); ?>
                        <div class="subtitle" style="text-align: left; border-top: 2px dotted #AAA"><?php echo $cont = $attachment->post_content; ?></div>
                    </object></center>
                    <?php break;
                 }
              }
    
           }
        }
        ?>
    	</div>  
    
    </div>

    As you can see what I'm doing is getting a new WP query to extract all the audio from the current category, then using that selection to create a "For each" loop where I declare some variables to extract the data from the files as url, tittle and content then put the [mp3j track=] shortcode with the values I just extracted.

    If you want to use this for the Player with the playlist just use the same principle but using some variables to modify the resulting loop to one string.

    Here I do that but for my files in the current page (Index) with an "if" that makes a playlist with the FEED:LIB if it doesn't find any file.

    <?php $mp3s = get_children( 'numberposts=-1&post_type=attachment&post_mime_type=audio&post_parent='.$post->ID );if (!empty($mp3s)) : ?>
    		<?php foreach($mp3s as $mp3): ?>
    			<?php $url= $mp3->guid; ?>
    			<?php $titl = $mp3->post_title; ?>
    			<?php  $cont = $mp3->post_content; ?>
          		<?php $fulurl .= $titl."@".$url.","; ?>
           		<?php $Capt .= $cont.";"?>
            <?php endforeach;?>
            	<?php echo mp3j_put( '[mp3-jplayer tracks="'.$fulurl.'" captions="'.$Capt.'" stop="n" list="y"]'); ?>
    		 <?php else: ?>
            	<?php echo mp3j_put( '[mp3-jplayer tracks="FEED:LIB" stop="n" list="y"]'); ?>
            <?php endif; ?>

    I'm sorry for my bad English and my messy code :/, I hope this help you to archive what you are trying to do.

    :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic