Audio Player
How can I add a Download Button to the Audio Player? (7 posts)

  1. BumpToThis.com
    Posted 4 years ago #

    Hello WordPress Community!

    I was hoping you guys could help me out. I wanted to add a download button the audio player, that allows the user to download the track that is being played in the audio player.

    Any ideas how I can go about doing this?


  2. Mr. Shiv
    Posted 4 years ago #

    I figured out how to add a download link.

    Use the WP plug-in editor to edit audio-player/audio-player.php. Find the sendToEditor() function, starting around line 696. In this short function, there's a block:

    if (strlen($matches[5]) > 0) {
    	$html = preg_replace("/]$/i", "|titles=" . $matches[5] . "]", $html);

    Add the following line immediately after that block:

    $html .= " <a href='" . $matches[3] . "'>[download]</a>";

    This will insert a [download] link just after (or below) the player, when you use the "Add Audio" button in your post, then the "Audio Player" button, and finally the "Insert into Post" button. In your Audio Player plugin settings, "Replace [audio] syntax" must be enabled, and "Replace all links to mp3 files" must be disabled.

    If you want a button, you could add a class to the link in the above code, and use some CSS to style it, or just hard code a button of your choice.

    This is a pretty crude shortcut, but it does work.

  3. BumpToThis.com
    Posted 4 years ago #

    Thanks man, you are awesome! Been waiting forever for a work around!

    Much Appreciated,
    Joe [ Signature moderated. ]

  4. Mr. Shiv
    Posted 4 years ago #

    Yeah, now if I can only get this to work in WP version 3.3.2. :(

  5. mew102
    Posted 4 years ago #

    Mr. Shiv, did you figure out how to get it to work in 3.3.2?

  6. Mr. Shiv
    Posted 4 years ago #

    Actually, it does work in 3.3.2 now. After a lot of frustration, I discovered that my hand-rolled theme had this crucial line in the wrong location:

    <?php wp_head(); ?>

    This bit of code should go in your header.php file. In my case, I was also using header.php to bring in some design elements from elsewhere on the site (i.e. outside of the WP blog portion of my site). Somehow this additional include() broke the functionality of wp_head(). After moving the wp_head() line down a bit in header.php, everything started working correctly.

  7. memelab
    Posted 4 years ago #

    I did this manually (once upon a time).. not hard if you don't have to enter too many :)

    • I manually add a link to the file in wordpress
    • disabled the function to auto-insert the player
    • style the link using css in my theme

    I did a walk through on my site back in 2008 :)
    Add a download button to WordPress Audio Player.

    You can find explicit instructions and a button to match the player.

    Never got around to making it into a plugin.. (which I reckon I'd do if there were filter hooks inside Martins player)

    hope it helps, tim

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic