Support » Plugins » [Plugin: Audio Player] Player in Custom Field not working

  • Hi,

    I’m happily using the AudioPlayer on my blog, and it used to work fine in the posts.

    Now I’m in the need to put it in a custom field of the post, but it shows me only the code line and not the Player.

    Is there a solution for my issue?

    Thx in advance for the support

Viewing 7 replies - 1 through 7 (of 7 total)
  • You can use insert_audio_player function for this. I show how to use it for adding a player to the sidebar here: http://wpaudioplayer.com/frequently-asked-questions

    You can pass it the value of a custom field.

    Martin

    Thanks a lot!!

    For anyone who had my problem:

    Create a custom field in the post called ‘player’

    Set the value with:
    [audio:http://www.domain.com/path/to/song.mp3%5D

    than place the code below in the place you prefer in the post template (or anywere else)

    `<?php $customField = get_post_custom_values(“player”);
    if ($customField) insert_audio_player( $customField[0]); ?>

    thx again doryphores!

    doryphores/smokingweb:

    I need to pass the value of the custom field…but have it work within a loop.

    I have this very close to working, but am missing one small piece.

    The screenshot:

    Viewable Here

    The code:

    Download Here

    Functions:

    Download Here

    We are looping through and outputting a list of items.

    I’ve had to replace the default audio player with a different one.

    The only problem is that the custom mp3 player is not looping — it just shows the first track_mp3.

    If I use:

    ‘echo get(“track_mp3”,$i, 1, false);’

    Then the shortcode — [audio:http://URLtoMP3.mp3] — displays instead of the player.

    @yourcustomblog

    This looks like an issue with how you retrieve the custom fields. I think what you should do is this:

    insert_audio_player(get("track_mp3",$i, 1, false));

    Martin

    Martin:

    That worked perfectly. I’d like to express my thanks here and via a donation, which you can expect shortly. I appreciate the free WordPress Audio Player plugin (which is a real success) and also your availability and advice via these support forums.

    Cheers…


    Peter

    For anyone out there interested in seeing the code — for using WP Audio Player plugin in conjunction with Flutter (replacing the default Flash .mp3 player), here you go:

    <?php
    $groupItems = jt_get_flutter_duplicates("track_name", "track_art");
    if (is_array($groupItems) && count($groupItems) > 0){
        foreach($groupItems as $i) {
    
    echo '<div style="background:#F5F5F5;border:1px solid #D8D8D8;padding:5px; margin: 10px 0 0 0;">';
    echo get_image("track_art",$i, 1, 1);
    echo '<h2 class="section-title" style="display:inline; margin-bottom:10px;">';
    echo get("track_name",$i, 1, false);
    echo '</h2>';
    echo '<div style="width:380px; float: left; display:inline; margin: 10px 0 0 0;">';
    $customField = get_post_custom_values("track_mp3");
    if ($customField)insert_audio_player(get("track_mp3",$i, 1, false));
    echo '</div>';
    echo '<br />';
    echo '<h2 class="section-title" style="display:inline;  margin: 0;">Buy This Track On:</h2>';
    echo '<ul class="buttons"><li>';
    echo get("track_amazon",$i, 1, false);
    echo '</li><li>';
    echo get("track_beatport",$i, 1, false);
    echo '</li><li>';
    echo get("track_itunes",$i, 1, false);
    echo '</li></ul>';
    echo '<div class="clear"></div>';
    echo '</div>';
        }
    }
    ?>

    Flutter duplicate fields code from: http://calisza.wordpress.com/2009/09/21/simplifying-flutter-duplicate-groups-and-fields/

    Here’s a cleaner version of the code:

    <!--start music box:  flutter custom fields-->
    
    <?php
    $track_names = get_post_meta($post->ID, "track_name", false);
    if ($track_names[0]=="") { ?>
    
    <!-- If there are no custom fields, show nothing -->
    
    <?php } else { ?>
    
    <!-- otherwise, do this! -->
    <?php
    
    $groupItems = jt_get_flutter_duplicates("track_name", "track_art");
    if (is_array($groupItems) && count($groupItems) > 0){
        foreach($groupItems as $i) {
    
    echo '<div style="background:#F5F5F5;border:1px solid #D8D8D8;padding:5px; margin: 10px 0 0 0;">';
    echo get_image("track_art",$i, 1, 1);
    echo '<h2 class="section-title" style="display:inline; margin-bottom:10px;">';
    echo get("track_name",$i, 1, false);
    echo '</h2><div style="width:380px; float: left; display:inline; margin: 10px 0 0 0;">';
    
    $customField = get_post_custom_values("track_mp3");
    if ($customField)insert_audio_player(get("track_mp3",$i, 1, false));
    
    echo '</div><br /><h2 class="section-title" style="display:inline;  margin: 0;">Buy This Track On:</h2><ul class="buttons">';
    
    $amazon = get("track_amazon",$i,1,false);
    if ($amazon)echo '<li><a class="amazon" target="_blank" href="' . get("track_amazon",$i,1,false). '">Button</a></li>';
    
    $beatport = get("track_beatport",$i,1,false);
    if ($beatport)echo '<li><a class="beatport" target="_blank" href="' . get("track_beatport",$i,1,false). '">Button</a></li>';
    
    $itunes = get("track_itunes",$i,1,false);
    if ($itunes)echo '<li><a class="itunes" target="_blank" href="' . get("track_itunes",$i,1,false). '">Button</a></li>';
    
    $yoshop = get("track_yoshop",$i,1,false);
    if ($yoshop)echo '<li><a class="yoshop" target="_blank" href="' . get("track_yoshop",$i,1,false). '">Button</a></li>';
    
    echo '</ul><div class="clear"></div></div>';
    
        }
    }
    ?>
    
    <?php } ?>
    
    <!--end music box flutter custom fields-->

    YourCustomBlog.com — WordPress Consultant

    I would like to get the file path, titles and artists all from their own custom field to make the updating a easier. I cant get the player to read id3 tags.

    Any ideas how to do this?

    All the values pulled from their own custom field
    [audio:your_mp3_file.mp3|titles=The title|artists=The artist]

    All help appreciated. Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: Audio Player] Player in Custom Field not working’ is closed to new replies.