Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if ( get_option('storefront_show_nav_player') == 'true' ) {?>
- <script>
- //<![CDATA[
- jQuery(document).ready(function($){
- // Local copy of jQuery selectors, for performance.
- var my_jPlayer = $("#jquery_jplayer"),
- my_trackName = $(".demo-container .track-name"),
- my_playState = $(".demo-container .play-state"),
- my_extraPlayInfo = $(".demo-container .extra-play-info");
- // Some options
- 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.
- opt_auto_play = true, // If true, when a track is selected, it will auto-play.
- opt_text_playing = "Now playing", // Text when playing
- opt_text_selected = "Track selected"; // Text when not playing
- // A flag to capture the first track
- var first_track = true;
- // Change the time format
- $.jPlayer.timeFormat.padMin = false;
- $.jPlayer.timeFormat.padSec = false;
- $.jPlayer.timeFormat.sepMin = " min ";
- $.jPlayer.timeFormat.sepSec = " sec";
- // Initialize the play state text
- my_playState.text(opt_text_selected);
- // Instance jPlayer
- my_jPlayer.jPlayer({
- ready: function () {
- $(".demo-container .track-default").click();
- },
- timeupdate: function(event) {
- my_extraPlayInfo.text(parseInt(event.jPlayer.status.currentPercentAbsolute, 10) + "%");
- },
- play: function(event) {
- my_playState.text(opt_text_playing);
- },
- pause: function(event) {
- my_playState.text(opt_text_selected);
- },
- ended: function(event) {
- my_playState.text(opt_text_selected);
- },
- swfPath: "js",
- cssSelectorAncestor: ".demo-container",
- supplied: "mp3",
- wmode: "window"
- });
- // Create click handlers for the different tracks
- $(".demo-container .track").click(function(e) {
- my_trackName.text($(this).text());
- my_jPlayer.jPlayer("setMedia", {
- mp3: $(this).attr("href")
- });
- if((opt_play_first && first_track) || (opt_auto_play && !first_track)) {
- my_jPlayer.jPlayer("play");
- }
- first_track = true;
- $(this).blur();
- return false;
- });
- });
- //]]>
- </script>
- <div id="jp_container" class="demo-container">
- <div style="font-size:12px;" align="center">Double click on the title to start the sample!</div>
- <?php
- $id = $post->ID;
- $featured_image = get_post_thumbnail_id($id);
- $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);
- $audiofiles = get_posts($arg);
- if ($audiofiles) {
- ?>
- <div id="jp_container" class="demo-container">
- <ul id="sft-single-product-tracks">
- <?php
- $arg = array( 'post_type' => 'attachment', 'orderby' => 'menu_order', 'order' => 'ASC', 'post_mime_type' => 'audio' ,'post_status' => null, 'post_parent' => $post->ID,'numberposts' => 1);
- $audiofiles = get_posts($arg);
- foreach ( $audiofiles as $audiofile ) {
- $alt = get_post_meta($audiofile->ID, '_wp_attachment_image_alt', true);
- ?>
- <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>
- <?php } ?>
- <?php
- $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);
- $attachments = get_posts($args);
- foreach ( $attachments as $attachment ) {
- $audiofile = wp_get_attachment_metadata( $attachment->ID , false );
- $alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
- ?>
- <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>
- <?php } ?>
- </ul>
- </div>
- <?php } ?>
- </div><!-- END AUDIO TRACK PLAYER -->
- <?php } //END CHECK FOR PLAYER ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement