Advertisement
Guest User

Untitled

a guest
Oct 11th, 2013
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php if ( get_option('storefront_show_nav_player') == 'true' ) {?>
  2. <script>
  3. //<![CDATA[
  4.  
  5. jQuery(document).ready(function($){
  6.  
  7.     // Local copy of jQuery selectors, for performance.
  8.     var my_jPlayer = $("#jquery_jplayer"),
  9.         my_trackName = $(".demo-container .track-name"),
  10.         my_playState = $(".demo-container .play-state"),
  11.         my_extraPlayInfo = $(".demo-container .extra-play-info");
  12.  
  13.     // Some options
  14.     var opt_play_first = true, // If true, will attempt to auto-play the default track on page loads. No effect on mobile devices, like iOS.
  15.         opt_auto_play = true, // If true, when a track is selected, it will auto-play.
  16.         opt_text_playing = "Now playing", // Text when playing
  17.         opt_text_selected = "Track selected"; // Text when not playing
  18.  
  19.     // A flag to capture the first track
  20.     var first_track = true;
  21.  
  22.     // Change the time format
  23.     $.jPlayer.timeFormat.padMin = false;
  24.     $.jPlayer.timeFormat.padSec = false;
  25.     $.jPlayer.timeFormat.sepMin = " min ";
  26.     $.jPlayer.timeFormat.sepSec = " sec";
  27.  
  28.     // Initialize the play state text
  29.     my_playState.text(opt_text_selected);
  30.  
  31.     // Instance jPlayer
  32.     my_jPlayer.jPlayer({
  33.         ready: function () {
  34.             $(".demo-container .track-default").click();
  35.         },
  36.         timeupdate: function(event) {
  37.             my_extraPlayInfo.text(parseInt(event.jPlayer.status.currentPercentAbsolute, 10) + "%");
  38.         },
  39.         play: function(event) {
  40.             my_playState.text(opt_text_playing);
  41.         },
  42.         pause: function(event) {
  43.             my_playState.text(opt_text_selected);
  44.         },
  45.         ended: function(event) {
  46.             my_playState.text(opt_text_selected);
  47.         },
  48.         swfPath: "js",
  49.         cssSelectorAncestor: ".demo-container",
  50.         supplied: "mp3",
  51.         wmode: "window"
  52.     });
  53.  
  54.     // Create click handlers for the different tracks
  55.     $(".demo-container .track").click(function(e) {
  56.         my_trackName.text($(this).text());
  57.         my_jPlayer.jPlayer("setMedia", {
  58.             mp3: $(this).attr("href")
  59.         });
  60.         if((opt_play_first && first_track) || (opt_auto_play && !first_track)) {
  61.             my_jPlayer.jPlayer("play");
  62.         }
  63.         first_track = true;
  64.         $(this).blur();
  65.         return false;
  66.     });
  67.  
  68. });
  69. //]]>
  70. </script>
  71.  
  72.     <div id="jp_container" class="demo-container">
  73.     <div style="font-size:12px;" align="center">Double click on the title to start the sample!</div>
  74.                             <?php
  75.                             $id = $post->ID;
  76.                             $featured_image = get_post_thumbnail_id($id);
  77.                             $arg = array( 'post_type' => 'attachment', 'orderby' => 'menu_order', 'order' => 'ASC', 'post_mime_type' => 'audio' ,'post_status' => null, 'post_parent' => $post->ID, 'exclude' => $featured_image,'numberposts' => 0);
  78.                             $audiofiles = get_posts($arg);
  79.                                 if ($audiofiles) {
  80.                                 ?>
  81.                                 <div id="jp_container" class="demo-container">
  82.                                 <ul id="sft-single-product-tracks">
  83.                                 <?php
  84.                                 $arg = array( 'post_type' => 'attachment', 'orderby' => 'menu_order', 'order' => 'ASC', 'post_mime_type' => 'audio' ,'post_status' => null, 'post_parent' => $post->ID,'numberposts' => 1);
  85.                                 $audiofiles = get_posts($arg);
  86.                                 foreach ( $audiofiles as $audiofile ) {
  87.                                 $alt = get_post_meta($audiofile->ID, '_wp_attachment_image_alt', true);
  88.                                 ?>
  89.                                 <li class="firsttrack"><a rel="<?php echo wpsc_the_product_title(); ?>" href="<?php echo wp_get_attachment_url( $audiofile->ID , false ); ?>" class="track track-default" id="foo"><?php if($alt) {echo $alt;} else {echo $audiofile->post_title;}?><span class="sft-single-product-track-play"></span></a></li>
  90.                             <?php   } ?>
  91.  
  92.  
  93.                                 <?php
  94.                                 $args = array( 'post_type' => 'attachment', 'orderby' => 'menu_order', 'order' => 'ASC', 'post_mime_type' => 'audio' ,'post_status' => null, 'post_parent' => $post->ID, 'exclude' => $featured_image,'numberposts' => 0,'offset'=> 1);
  95.                                 $attachments = get_posts($args);
  96.                                 foreach ( $attachments as $attachment ) {
  97.                                 $audiofile = wp_get_attachment_metadata( $attachment->ID , false );
  98.                                 $alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
  99.                                 ?>
  100.                                 <li><a rel="<?php echo wpsc_the_product_title(); ?>" href="<?php echo wp_get_attachment_url( $attachment->ID , false ); ?>" class="track"><?php if($alt) {echo $alt;} else {echo $attachment->post_title;}?><span class="sft-single-product-track-play"></span></a></li>
  101.                             <?php   } ?>
  102.                            
  103.                                
  104.                            
  105.                            
  106.                                
  107.                                 </ul>
  108.                                 </div>
  109.                                 <?php } ?>
  110.         </div><!-- END AUDIO TRACK PLAYER -->
  111. <?php } //END CHECK FOR PLAYER ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement