• 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 by Jason

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

  • Product Review: LaCie Iamakey – A Durable USB Key
    In Hardware, Gadgets, and Products, Reviews
  • Touring Blue Waters – The National Petascale Computing Facility
    In Going Green, Hardware, Gadgets, and Products, News
  • KeySweeper USB wall charger could be keylogging you
    In Security and Privacy

Latest Media Posts

Find Out Where To Download SNES ROMs

Find Out Where To Download SNES ROMs

Multifunctional Video Conversion Tools – Wondershare Video Converter

Multifunctional Video Conversion Tools – Wondershare Video Converter

  • Popular
  • Latest
  • Today Week Month All
  • How to ‘Unblock’ multiple files at a time with PowerShell How to 'Unblock' multiple files at a time with PowerShell
  • Increase IIS Private Memory Limit to improve WSUS availability Increase IIS Private Memory Limit to improve WSUS availability
  • Command line to take ownership and change permissions Command line to take ownership and change permissions
  • Creating and editing views in phpMyAdmin Creating and editing views in phpMyAdmin
  • Read the Event Logs on Windows Server Core Read the Event Logs on Windows Server Core
  • How to Purchase Cryptocurrencies? How to Purchase Cryptocurrencies?
  • Top 6 necessary aspects to consider when hiring Angular developers Top 6 necessary aspects to consider when hiring Angular developers
  • Full guide on drawbacks and benefits of Node.js for making the perfect choice for your business Full guide on drawbacks and benefits of Node.js for making the perfect choice for your business
  • Benefits of End-To-End Testing That Will Match Company Expectations Benefits of End-To-End Testing That Will Match Company Expectations
  • 3 Key Features of Pets Health Monitoring Systems 3 Key Features of Pets Health Monitoring Systems
Ajax spinner

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.

Recent Posts

  • How to Purchase Cryptocurrencies?
  • Top 6 necessary aspects to consider when hiring Angular developers
  • Full guide on drawbacks and benefits of Node.js for making the perfect choice for your business

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 © 2023 · Magazine Pro Theme on Genesis Framework · WordPress · Log in