phpBB3 MP3 Player with Attachments

MP3 Player - August 23rd, 2010

phpBB has a great attachment tool that gives users the ability to upload multiple files, if you have a podcast or own a music site, the most essential of these will be the MP3 extension. The code that you’re going to find on this page is not relevant to any other part of the attachment mod besides the MP3 file. I understand that the video support is not top notch either. The problem is that there is too many different extensions and they all need to be tackled individually.

What we are going to do is provide any user who decides to upload an MP3 file on your forum a flash player that plays the song and gives you a download link on the same page. A couple scripts that we borrowed from to do this very simple task were missing key parts.

For example, one had a less standard flash player, the other didn’t allow you download the MP3 file anymore, and there was a great one that only would add the flash player by clicking the inline option after you uploaded it. Mine is 100 percent automatic after you upload the file.

Almost all of them conflicted with other attachments to some degree, but were great ideas that only took me a few hours to improve on.

I’ve made sure to test this modification out. The instructions are perfect and all there. I can’t guarantee that it will work in future versions of phpBB3, but this page will surely have an update if that isn’t the case because this mod is very essential to one of my forums.

The MP3 Player is brilliant and a universally accepted one that allows you to playback, rewind, fast forward and displays the name of the track.

A cool feature that you might overlook is the ability to use the bbcode tag [mp3] anywhere on your site which makes it extremely simple for your users to move songs from one forum to another. If enough people request it, I can make this happen off the site as well.

Features

*Fast MP3 Player
*Download MP3 & listen on the same page
*Use the MP3 tag anywhere on your forum to embed uploaded song
*Uses Attachment Mod
*Very simple to install
*Works with SubSilver2 and Prosilver
*Change Color of Flash Player, Loop, or Autostart

Step 1: Download the player

First you will need to download this player (right-click, Save as…). It is an .swf file; this is what will be used to allow you to playback your MP3 files.

Step 2: Upload Player

Upload the flash .swf file to your forums root directory. We will get back to that later in this easy tutorial that I promise will be done in 10 minutes.

Step 3: Code Changes

Open

/includes/constant.php

Find

define('ATTACHMENT_CATEGORY_QUICKTIME', 6); // Quicktime/Mov files

Add After

define('ATTACHMENT_CATEGORY_MP3', 7); // MP3 Files - Streaming

Open

/includes/functions_content.php

Find

	// Windows Media Streams
				case ATTACHMENT_CATEGORY_WM:
					$l_downloaded_viewed = 'VIEWED_COUNT';

					// Giving the filename directly because within the wm object all variables are in local context making it impossible
					// to validate against a valid session (all params can differ)
					// $download_link = $filename;

					$block_array += array(
						'U_FORUM'		=> generate_board_url(),
						'ATTACH_ID'		=> $attachment['attach_id'],
						'S_WM_FILE'		=> true,
					);

					// Viewed/Heared File ... update the download count
					$update_count[] = $attachment['attach_id'];
				break;

Add After

    // MP3 Streams
                case ATTACHMENT_CATEGORY_MP3:
                   $l_downloaded_viewed = 'VIEWED_COUNT';

                   $block_array += array(
                      'U_FORUM'      => generate_board_url(),
                      'ATTACH_ID'      => $attachment['attach_id'],
                      'S_MP3_FILE'      => true,
                   );

                   // Viewed/Heared File ... update the download count
                   $update_count[] = $attachment['attach_id'];
                break;

Open

includes/acp/acp_attachments.php

Find

ATTACHMENT_CATEGORY_FLASH		=> $user->lang['CAT_FLASH_FILES'],
ATTACHMENT_CATEGORY_QUICKTIME	=> $user->lang['CAT_QUICKTIME_FILES'],

Add After

ATTACHMENT_CATEGORY_MP3         => $user->lang['CAT_MP3_FILES'],

Open

language/en/acp/attachments.php

Find

$cat_lang = array(
....
'CAT_QUICKTIME_FILES'		=> 'Quicktime media files',

Add After

'CAT_MP3_FILES' => 'MP3',

Open

styles/template/attachments.html

Find

Works for Subsilver2 and Prosilver

<script type="text/javascript">
			// <![CDATA[
				if (document.rmstream_{_file.ATTACH_ID}.GetClipWidth)
				{
					while (!document.rmstream_{_file.ATTACH_ID}.GetClipWidth())
					{
					}

					var width = document.rmstream_{_file.ATTACH_ID}.GetClipWidth();
					var height = document.rmstream_{_file.ATTACH_ID}.GetClipHeight();

					document.rmstream_{_file.ATTACH_ID}.width = width;
					document.rmstream_{_file.ATTACH_ID}.height = height;
					document.ctrls_{_file.ATTACH_ID}.width = width;
				}
			// ]]>
			</script>

Add After

Replace yoururl.com with your forums address.


	<!-- ELSEIF _file.S_MP3_FILE -->

<object type="application/x-shockwave-flash" data="http://yoururl.com/player.swf" id="audioplayer1" height="24" width="290">
<param name="movie" value="http://yoururl.com/player.swf" />
<param name="FlashVars" value="playerID=1&soundFile={_file.U_DOWNLOAD_LINK}" />
<param name="quality" value="high" />
<param name="menu" value="true" />
<param name="wmode" value="transparent" />
</object><br/>
<span class="gensmall">
	<!-- IF _file.UPLOAD_ICON -->{_file.UPLOAD_ICON} <!-- ENDIF -->

<a href="{_file.U_DOWNLOAD_LINK}">{_file.DOWNLOAD_NAME}</a><br/> [ {_file.FILESIZE} {_file.SIZE_LANG} | {_file.L_DOWNLOAD_COUNT} ] </span>

Find

Only if you want to change the color, autostart or loop for the flash player.

&playerID=1&

Add After

bg=0x9DA5BF&amp;leftbg=0xeeeeee&amp;lefticon=0x666666&amp;rightbg=0x394670&amp;rightbghover=0x999999&amp;righticon=0xE7E7EF&amp;righticonhover=0xffffff&amp;text=0x666666&amp;slider=0x666666&amp;track=0xFFFFFF&amp;border=0x666666&amp;loader=0x9FFFB8&amp;loop=no&amp;&autostart=no&amp;&

Step 4: Extension Settings

The easiest part!

Open phpBB3 Admin Control Panel

Go to the posting tab.

Under “Manage Extensions” add “mp3” under the group “files MP3”.

Under “Manage Extension Groups” add “Files MP3”, select the “MP3” for a special category and any other settings that you like.

Under “Manage Extensions” verify that the “MP3” extension is filed under “MP3 Files”.

Step 5: MP3 BBCode

Not necessary, only if you want to be able to move the flash player to different forums.

Navigate to Posting BBcodes.

BBCode usage

Add New

[mp3]{URL}[/mp3]

HTML replacement

Add New

<object type="application/x-shockwave-flash" data="http://yourwebsiteurl.com/player.swf" id="audioplayer1" height="24" width="290">
<param name="movie" value="http://yourwebsiteurl.com/player.swf" />
<param name="FlashVars" value="playerID=1&soundFile={URL}" />
<param name="quality" value="high" />
<param name="menu" value="true" />
<param name="wmode" value="transparent" />
</object>

Help Line

Add New

[mp3]URL to file[/mp3]

That’s it!

Acknowledgement

Thanks 404 Tech Support especially and this non english forum for giving us the tools to make this mod possible.

If you feel that any work that you might have contributed to this small mod was not acknowledged in this article feel free to leave a comment with a link to your website. Feel free to ask for improvements, I’d be glad to consider them.

Posted in Tips & Code
Tags: ,

39 ResponsesComments Feed

  1. Vinnie

    Thank you so much for the instruction. I use this player for phpBB 3.0.7-PL1. It works !

    09/10/10, 10:28 am
  2. Robin

    I try to install this mod today, but i got a problem until step 4…

    You wrote:
    Under “Manage Extensions” add “mp3″ under the group “files MP3″.

    But i have no “files MP3” in my list of the extension group. And the strangest thing… I can only select from some german points from the quick menu (i running a german board on my server). I set my admin profile to the english lang. but it’s still in german there. I check my modifications three times now, but all is fine until the point 4.

    Any idea?

    09/12/10, 2:55 pm
  3. I am able to go through most of the steps except for Step 4. I do not see the special category: mp3 under the options for the group extensions management option. Please help me troubleshoot this. My website is http://www.songcritiques.com.

    Thank you.

    Carlos

    09/13/10, 8:11 pm
  4. Robin

    My problem is solved…I was only a bit irritated around the “Manage extension” and “Manage extension group”. I also found the “problem” with my german description. They are safed under the “Manage extension groups” (only on localized versions of phpBB).

    Solution:
    1. Under “Manage extensions groups” at the “POSTING” tab ad under “Create new group” the word “MP3” or “MP3 files” (what you prefer). Click on “Submit” to safe it.
    2. Select under the “Special category” something else from the quick menu. I choose “None”. Than select what you will allowed (Posting on the board / posting on PM), select your max. upload size for MP3’s (I think 5 MB is good) and as least select on wich boards you will allow an MP3 upload (all boards or only your selected one). Click now on “Submit” if you are done with your settings.
    3. Select now in the “POSTING” tab the point “Manage extension”. Search for the suffix “MP3” who’s placed at the moment under “Loadable files” (I’m not sure if this the exactly word in english for this point). Now you can change it from this status to “MP3” over the quick menu. Click on “Submit” to safe your new settings.

    With this settings i have now access to the MP3 flash player. But at the moment only for direct linked mp3’s. Uploaded MP3’s are still didn’t work for me. Not sure what’s the problem at the moment. If i understand it right, this must work with this plugin/concept.

    09/15/10, 2:32 pm
  5. Robin

    Oh… i forget one important information for step 2!!!

    Under “Assigned extension” you will see something who suggest a list, but you can’t insert anything or choosing anything… There is only a link who named “Go to extension management screen”. If you do this, you will lost your settings if you didn’t click on “Submit” before and you didn’t will get an access on your new group category named “MP3”.
    But if you safe your settings now and make the settings under step 3, this will put automatically the assigned extension to the “Manage extension group” settings. You can recheck it if you click after all steps who i wrote down, if you edit (green icon) now the MP3 settings.

    I hope you understand what i would say… I’m not absolutely perfect with my english 😉

    09/15/10, 2:39 pm
  6. I’m still having problems. Any response from qkin?

    09/15/10, 9:21 pm
  7. Thanks Robin. I’m able to get the BBcode player to work now, but not the attachment MP3 player. I think it’s because we can’t select “MP3” as an option under the special category for group extension managements.

    Any thoughts, qkin?

    09/16/10, 2:11 am
  8. Ok. I figured how to make it work. There are two sections in the acp_attachments.php file where you need to add this line:

    ATTACHMENT_CATEGORY_MP3 => $user->lang[‘CAT_MP3_FILES’],

    Make sure to add the line to both sections so you will see “MP3” on the drop-down menu for special category selection under the group extensions management area.

    09/16/10, 3:08 am
  9. Now, is there a way to remove the download link from the MP3 player so people can’t download the file easily?

    09/16/10, 3:10 am
  10. i m having the problem, now i can upload the mp3 files but the problem is that player is not getting visible in the discussion forum

    10/08/10, 5:38 pm
  11. The player doesn’t show up in the attachment
    I have followed the instructions.
    What could be wrong ?

    10/10/10, 2:43 am
  12. Thanks Carlos for explaining that & Robin.

    ———————————-

    Here’s how to remove the download link.

    phpBB3 Mp3 Fix

    Frank please check functions_content.php and make sure that the edits you made were correct.

    10/11/10, 2:31 am
  13. Thank You qkin for posting this article.
    I’ve followed all the steps instructed, mp3 icon’s showing next to font colour. [ Font Colour mp3 ]
    Here the code i’ve inserted:
    mp3]http://lasan92.net/ls92/nhac/singles/Blue.Danube.mp3[/mp3]

    The result: Test [which is topic name]
    No player’s showing, no song play…

    What did i do wrong?
    Your assistance is hightly appreciated.

    Best Regards,
    /ksdh

    12/02/10, 6:17 pm
  14. Issues Resolved.
    It’s Working now.
    Thank You!

    /ksdh

    12/03/10, 12:24 am
  15. on your bbcode don’t forget to change the “yoururl” to your URL
    after uploading your files purge your templates.

    12/04/10, 7:55 pm
  16. on your language/en/acp/attachments.php
    don’t forget to make those changes to your other languages you are using.

    also do the same changes to all your templates.

    12/04/10, 8:37 pm
  17. Nelson

    i got as far as the step “styles/template/attachments.html”..i am using a rocket theme and that file does not exist. how can i add this to my template?

    02/07/11, 3:28 am
  18. I wish I could do it on a smf forum

    02/25/11, 5:17 am
  19. qkinweb

    @ Nelson. Template means Rocket!

    02/25/11, 2:30 pm
  20. Nhaw-T

    oh man! i cant really follow the steps from step 1… just newly to configure phpbb..just hoping if u can make a video tutorial.. thanks in advance!

    02/26/11, 5:29 am
  21. this_sux

    you cant download the .swf file in win 7 bummer

    can some one post a link to it ?

    03/12/11, 11:25 am
  22. qkinweb

    Hope this works for you, if not, I have an instant messenger listed on phpBB.com.

    http://www.mediafire.com/?icl0b51p6qaae9s

    03/16/11, 2:12 am
  23. Hey there,

    Having issues getting the flash player to show under the attachment window. Have spent hours on this, checking the URL of the .swf, checking the code in attachments.html, etc etc.

    I’ve basically set this up and gone through the guide about 3 times with no help, including the hints of the comments page here and on the mods forum.

    Any ideas?

    03/25/11, 3:45 pm
  24. ihng

    is there a way by using the bbcode to show the link (url) under the player. now if you only add the player per bbcode you dont what do you hear and you don’t know a link to download the mp3.

    03/25/11, 8:16 pm
  25. Hey guys,

    If any of you are having issues with the player not showing, make sure you purge your cache in the admin panel before mucking around too much.

    Finally figured out that is was the issue with my forum.

    03/27/11, 7:29 pm
  26. includes/acp/acp_attachments.php

    ==========
    ATTACHMENT_CATEGORY_FLASH => $user->lang[‘CAT_FLASH_FILES’],
    ATTACHMENT_CATEGORY_QUICKTIME => $user->lang[‘CAT_QUICKTIME_FILES’],

    =======
    Need to find twice!!

    04/17/11, 7:21 am
  27. Jeppe

    Thanks for the mod – difficult to install but perfect once installed 🙂

    05/10/11, 5:13 pm
  28. qkinweb

    @ Jeppe. How about you just use pastebin for your addon? Please, and thank you for the addition.

    05/11/11, 12:59 pm
  29. I had the player working for a while, now all it does is buffer and doesn’t play anymore. Anybody know what may be causing this. Can anyone here fix it for me?

    05/13/11, 11:26 am
  30. swapvn

    I had the same Joesph’s problem the player working for a while, now the player not showing.
    Some one helps me please. Thanks

    09/14/11, 2:47 am
  31. roliignorne

    Here i entertain organize some awesome clarinets for richest prices. Soprano clarinets incorporate the timeless rich, harmonious tones people typically keep flock with this most bountiful myself in the woodwind family.
    http://www.buyclarinet.netai.net

    10/14/11, 10:01 pm
  32. alydhiends

    Hi, how do I put back the comments in the attachment? It seems to be gone.

    Thanks

    11/15/11, 10:41 am
  33. alydhiends

    nvm, I got it working now.

    styles/prosilver/template/attachment.html

    find

    below that, find

    Before the “”, insert this:
    {_file.COMMENT}

    Purge your cache in the ACP & That’s it 🙂

    11/15/11, 11:04 am
  34. alydhiends

    Oh Well, there seems to be a problem posting codes here. Let me explain it again.

    styles/prosilver/template/attachment.html

    Find:
    file.COMMENT

    Copy that whole line

    Find:
    ELSEIF _file.S_MP3_FILE

    Further down you will find:
    span class=”gensmall”

    Before the Span closing tag, insert the line you just copied.

    Purge the cache in your ACP & that’s it.

    11/15/11, 11:11 am
  35. Ok, I have read, and re-read and then re-read again, everything on this post and I did everything as you guys are saying… It doesn’t do anything! I cannot for the life of me get the player to appear! It doesn’t with attachments or URLs… Nothing!
    My only difference is in the template where I use a different than Subsilver2 or Prosilver, I use Acidtech yellow but I did edit correctly its own attachment.html.
    Any help would be greatly appreciated!
    Regards

    12/13/11, 6:27 pm
  36. QKin, please forgive me and disregard or better yet kill my last post… I guess I wasn’t reading well enough! It now works!
    Thank you again for the great post!!! 😉

    12/13/11, 6:46 pm
  37. alfred beilin

    hi happy new year to yous all
    alf beilin

    01/02/12, 5:05 pm
  38. achim82

    Happy new year to all of you…
    I had no proplem including this to my forum. All works fine, except that when i push play it’s buffering for 2 seconds and the message “Error opening file” appears.
    Any suggestions?

    01/05/12, 7:54 am
  39. revjombo

    I know this is old but I stumbled on it trying to figure out how to stop the download link appear when I post an attachment for the player I have that does work. I never could get this one to play it always errors and file not found.

    I have a mod that does this fine but I want to stop the showing of the download link for the mp3 lol. But I hacked at a test forum here for 4 hours and all I got from it was same as achim82. Besides this mp3player has no volume control that makes it bad IMO, I use Dewplayer and a different mod. But darn them download links.

    04/13/12, 3:18 am

Leave a Reply

Your email address will not be published. Required fields are marked *