• Home
  • About 404TS
  • Contact

404 Tech Support

Where IT Help is Found

  • Articles
    • Code
    • Entertainment
    • Going Green
    • Hardware, Gadgets, and Products
    • Management
    • Network
    • News
    • Operating Systems
    • Security and Privacy
    • Software
    • System Administration
    • Talking Points
    • Tech Solutions
    • Web
    • Webmaster
  • Reviews
  • Media
    • Infographics
    • Videos
  • Tech Events
  • Tools
    • How do I find my IP address?
    • Browser and plugin tests
  • Get a Technical Consultation
You are here: Home / Media / An MP3 Player for Inline MP3 Attachments in phpBB3

An MP3 Player for Inline MP3 Attachments in phpBB3

2009-08-12

phpBB has some really neat features for file attachments that you might use automatically with a post. For example, if you upload an image and hit the button “Place Inline”, some BBcode will be added to the text box and when you preview or submit your post the image will be rendered inside of the post instead of just a link to download the image. Similarly, if you upload a .wma file and place it inline, you will get the Windows media player to play this file back to anybody viewing that post. Unfortunately, no such thing exists by default for .MP3 files, the popular audio format.

I’ve previously covered how to create a BBcode that will take the URL to an MP3 file and create an embedded Flash player for that file in a post (along with other very handy BBcodes). You could even upload an MP3 file as an attachment and then take the URL to that file and put it into the MP3 BBcode and everything would work just fine.

player


Now, we’re going to take that modification a step further and make it so that if you upload an MP3 file and you click the “Place Inline” button, it will put the file URL in the text box and wrap it in the [mp3][/mp3] BBcodes automatically.
inline

Step 1: Download the player

You’ll need to download this player (right-click, Save as). It is an .swf file; this is the actual flash player that provides an interface and the means to playback .mp3 files.

Step 2: Upload the player to your server

Upload the .swf file you just downloaded to some location on your server and note the path to it. It will need to have permissions set to be publicly readable.

Step 3: Create the BBcode

In order to add more BBcodes, log into the Administration Control Panel. There, go to the Posting tab, and then BBCodes. Click the “Add a new BBCode” grey button to get to the next page where you can configure your new entries. Create a new BBcode with the following information. You can decide for yourself if you want it shown on the posting page or not. If you need further help with this step, see my previous post on Essential BBcodes. Be sure to use the correct code that points to where you uploaded the player.swf file you downloaded in step 1.

BBCode: [mp3]{URL}[/mp3]

HTML:

[html]<object type="application/x-shockwave-flash" data="http://yourforum.com/mp3player/player.swf" id="audioplayer1" height="24" width="290">
<param name="movie" value="http://yourforum.com/mp3player/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>
[/html]

Help line: [mp3]URL to file[/mp3]

Step 4: Modify two files.

Create a back up copy of each of these files. Then modify these files and upload them back to your server.

phpbbRoot/styles/prosilver/template/editor.js

Find:

[javascript]/**
* Add inline attachment at position
*/
function attach_inline(index, filename)
{insert_text(‘[attachment=’ + index + ‘]’ + filename + ‘[/attachment]’);
document.forms[form_name].elements[text_name].focus();
}[/javascript]

Replace with (Be sure to update the code so that it is pointing to the correct location for your forum):

[javascript]/**
* Add inline attachment at position
*/
function attach_inline(index, filename, attach_id)
{
if (filename.match(".mp3"))
{
insert_text(‘[mp3]’ +’http://yourforumURL.com/download/file.php?id=’ + attach_id +'[/mp3]’+’ ‘ + filename);
document.forms[form_name].elements[text_name].focus();
}
else
{
insert_text(‘[attachment=’ + index + ‘]’ + filename + ‘[/attachment]’);document.forms[form_name].elements[text_name].focus();
}
}[/javascript]

phpbbRoot/styles/prosilver/template/posting_editor.html

Find:

[javascript]<input onclick="attach_inline({attach_row.ASSOC_INDEX}, ‘{attach_row.A_FILENAME}’);" type="button" value="{L_PLACE_INLINE}" />[/javascript]

Replace with:

[javascript]<input onclick="attach_inline({attach_row.ASSOC_INDEX}, ‘{attach_row.A_FILENAME}’, ‘{attach_row.ATTACH_ID}’);" type="button" value="{L_PLACE_INLINE}" />

<!– ENDIF –>[/javascript]

Step 5: Purge the cache

In the Administration Control Panel, under the General tab, click the ‘Run now’ button across from “Purge the cache.”

Step 6: Test it out!

Go to your forum and create a new post. Upload an .mp3 file and hit the button to “Place Inline” as soon as the upload finishes. In the text area, you should get some text inserted that appears like in the following screenshot.

result

Original credit goes to this site, The Koumjian Review, but I use a different Flash player, only edit two files, and corrected a number of bugs and syntax errors from that post. If you’d like to test this functionality out, you can post in the comments to this article in the forum by following the link below.

Filed Under: Media, Webmaster

Trending

  • Microsoft releases EMET 5.5
    In Security and Privacy, Software
  • Intel Compute Stick, a sold out success?
    In Hardware, Gadgets, and Products
  • Is it Possible to Live by Best Practices?
    In System Administration, Tech Solutions

Latest Media Posts

Multifunctional Video Conversion Tools – Wondershare Video Converter

Multifunctional Video Conversion Tools – Wondershare Video Converter

The WannaCry Post-Mortem

The WannaCry Post-Mortem

  • Popular
  • Latest
  • Today Week Month All
  • Microsoft Word: “This modification is not allowed because the selection is locked.” Microsoft Word: "This modification is not allowed because the selection is locked."
  • How to edit the message subject in Outlook 2016 How to edit the message subject in Outlook 2016
  • What is the AllJoyn Router Service on Windows 10? What is the AllJoyn Router Service on Windows 10?
  • Increase IIS Private Memory Limit to improve WSUS availability Increase IIS Private Memory Limit to improve WSUS availability
  • Scan-To-Email with Office 365 from a multifunction copier or printer Scan-To-Email with Office 365 from a multifunction copier or printer
  • 5 Factors To Look At When Choosing Web Hosting 5 Factors To Look At When Choosing Web Hosting
  • How managers can improve their team’s written communication skills How managers can improve their team’s written communication skills
  • Online Casino Technology – How Does It All Work? Online Casino Technology – How Does It All Work?
  • Virtual Assistant Devices Will Reshape Your Life in 2019 Virtual Assistant Devices Will Reshape Your Life in 2019
  • The 5 Most Common Problems with PC Gaming The 5 Most Common Problems with PC Gaming
Ajax spinner

Upcoming Tech Events

There are no upcoming events at this time.

Elevator Pitch

404 Tech Support documents solutions to IT problems, shares worthwhile software and websites, and reviews hardware, consumer electronics, and technology-related books.

Subscribe to 404TS articles by email.

Follow Us

  • Facebook
  • Google+
  • RSS
  • Twitter
  • YouTube

Recent Posts

  • 5 Factors To Look At When Choosing Web Hosting
  • How managers can improve their team’s written communication skills
  • Online Casino Technology – How Does It All Work?

Search

FTC Disclaimer

404TechSupport is an Amazon.com affiliate; when you click on an Amazon link from 404TS, the site gets a cut of the proceeds from whatever you buy. This site also uses Skimlinks for smart monetization of other affiliate links.
Use of this site requires displaying and viewing ads as they are presented.

Copyright © 2019 · 404TechSupport.com