An FLV Player and BBcode for Inline FLV Attachments in phpBB3
Upon request, I began looking into how to modify my previous post regarding how to embed MP3 attachments with a Flash player on a phpBB3 forum to also allow the same thing for FLV videos. After following this article, in your phpBB3 forum you’ll be able to use a BBCode to play .flv files as well as upload .flv files and embed them to play with a single click on the “Place Inline” button under the attachment.
The Player
.FLV files, unlike .SWF files, require a player to control them. SWF files can simply be embedded using the default [flash] BBCode. An .flv file would require a player to be called pointing to the .flv file. You can acquire the popular and free (for noncommercial uses) JW FLV Media Player. Visit the Longtail website and download the JW FLV Player by checking the “I agree to the noncommercial license” and hitting the ‘Download Now’ button.
The download is in the form of a .zip file. Extract the files from the zip file to a folder on your desktop and upload those seven (7) files to a folder on your server. Make sure the player.swf file’s permission allow it to be accessed from the web. Note the URL to the player.swf file for later use.
Next, you’ll need to generate the code to embed the player. Here you can easily choose a bunch of different options using Longtail’s JW Player Setup Wizard.
Step 1 should be “flvplayer with a single video” but the rest of the options you can go through and choose for yourself on how you want the player to operate. One of the values I changed was under Embed parameters. For the source, replace player.swf to the URL you noted earlier to the player.swf file on your server. You can also change the height and width to a size you might use more frequently. Under File properties, you should also change the ‘file’ line to ‘{URL}’ like in the screenshot below. The rest of the values I left as the default, but you can freely choose to configure them as you wish. Hit the ‘Update Preview & Code’ button when you’re done.
Scroll down to step 3 and see if you approve the player’s look and behavior. If not, scroll back up to step 2, make any changes, and update the preview again. Once the player is how you want it, scroll down to step 4 and click the use ‘the embed code link’.
This will switch the code to begin with an embed tag. Copy this code and then go on to create the BBCode to be used on your forum.
The BBCode
Log into the Administration Control Panel of your phpbb forum and browse to the Posting tab and the BBCodes selection. Click the ‘Add a new BBCode’ button to create an FLV bbcode.
The BBCode usage field should be filled out with code like this:
[flv]{URL}[/flv]
and the HTML replacement field should have the code you copied from the JW Player Setup Wizard that began with the embed tag.
If you want just the default HTML replacement like I generate, it should be something like this: (Be sure to switch the src= value to the URL of your player.swf file.)
<embed
src='http://yoursite.com/flvplayer/player.swf'
width='480'
height='360'
bgcolor='undefined'
allowscriptaccess='always'
allowfullscreen='true'
flashvars='file={URL}'
/> |
You can optionally choose to have a help line or have the bbcode displayed on the posting screen. The settings should appear like below and then hit the Submit button.
Now people will be able to post to your forum with a URL to an .flv file, surround it with the [flv] bbcode, and have a player appear.
[flv]http://somewebsite.com/viralvideo.flv[/flv]
You could create different BBCodes if you wanted different behaviors like auto-play or different sizes.
Extensions
In order for people to be able to upload an .flv file, the extension permissions will need to be configured to allow this. In the Administration Control Panel again, go under the Posting tab and then click on the ‘Manage extensions’ link. This will bring up the extension management page on the right side. Add flv as an extension and add it to the Downloadable files Extension group. Then hit the ‘Submit’ button. You’ll also need to go into the Manage extension groups page and ensure tha Downloadable Files are allowed.
File Editing
Assuming you’ve already performed the mod to allow inline MP3 attachments, there is only one file to modify now. If you haven’t performed the MP3 attachment mod, you will need to view that article: An MP3 Player for Inline MP3 Attachments in phpBB3 and follow the steps for modifying phpbbRoot/styles/prosilver/template/posting_editor.html
Similar to the MP3 attachment mod, we’ll need to edit the file at phpbbRoot/styles/prosilver/template/editor.js
Make a backup copy of this file before you begin working. Then find this section of the code around line 195:
/** * Add inline attachment at position */ function attach_inline(index, filename) { insert_text('[attachment=' + index + ']' + filename + '[/attachment]'); document.forms[form_name].elements[text_name].focus(); } |
Replace it with this code:
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | function attach_inline(index, filename, attach_id) { if (filename.match(".mp3")) { insert_text('[mp3]' +'http://yourserver.com/download/file.php?id=' + attach_id +'[/mp3]'); document.forms[form_name].elements[text_name].focus(); } else if (filename.match(".flv")) { insert_text('[flv]' +'http://yourserver.com/download/file.php?id=' + attach_id +'.flv[/flv]'); document.forms[form_name].elements[text_name].focus(); } else { insert_text('[attachment=' + index + ']' + filename + '[/attachment]'); document.forms[form_name].elements[text_name].focus(); } } |
If you have already performed the MP3 mod, you’ll only need to add the ‘else if’ section to the code.
Save the changes you have made and upload the modified file to replace the original.
Log into the Administration Control Panel of the forum and hit the button to ‘Purge the cache’.
Now, take the mod for a whirl. You should be able to upload an attachment of a file with extension .flv, click the Place Inline button, and have the code appear in the posting box.

When you submit the post, you should now see the videos successfully. They’re just waiting for somebody to press play.
Check out the comments in our forum to see this mod in action or post any related questions.
Comment on this post in our forums
Related posts:











September 29th, 2009 at 8:11 PM
As a URL to the flv with bbcode:
width='480'
height='360'
bgcolor='undefined'
allowscriptaccess='always'
allowfullscreen='true'
flashvars='file=http://spence-animator.co.uk/flashvideo.flv'
/>
[flv]http://mysite.com/subfolder/flashvideo.flv[/flv]As an attachment:
width='480'
height='360'
bgcolor='undefined'
allowscriptaccess='always'
allowfullscreen='true'
flashvars='file=http://par.404techsupport.com/download/file.php?id=249.flv'
/>
[flv]http://par.404techsupport.com/download/file.php?id=249.flv[/flv]September 30th, 2009 at 6:19 AM
Thanks for writing up the tutorial.
This is pretty much what I did before but the attachment still doesn’t play like I explained in my first post.
I followed your tutorial again from scratch but have the same issue – it works as a manual embed linking the absolute url myself but the inline attachment part fails to work/play.
Also on your tutorial when you add .flv to downloadable extensions you should enable downloadable extensions in posts from manage extension groups too shouldnt you? which I did
I still get this
September 30th, 2009 at 7:10 AM
What’s the URL to the video.flv attachment at the bottom of that post?
What did you use to post those two videos? Is the first one a URL to the video? The second one the attachment? What happens if you do the bbcode around the attachment URL + .flv? It would be something like:
http://mysite.com/subfolder/download/file.php?id=49.flv
Does that work?
It sounds like a permissions problem. Are you able to download the attachment by clicking on the video.flv file? You might need to check in your Groups permissions and Groups’ forum permissions that people are able to attach files and download files. I assume you’re checking from an administrator account, so that probably isn’t the problem.
September 30th, 2009 at 7:22 AM
The first works and is:
[flv]http://mysite.com/subfolder/video.flv[/flv]The second doesn’t work and is:
[flv]http://mysite.com/subfolder/download/file.php?id=49.flv[/flv]Yes I am logged in as the Administrator and all permissions on for my group. Yes, I CAN download by clicking on the link.
September 30th, 2009 at 8:49 AM
Can you create a user for me to check it out on your forum or enable registration?
September 30th, 2009 at 8:51 AM
Ok. Registration is enabled. I’ll leave it enabled for a short while.
September 30th, 2009 at 9:25 AM
It seems to work for me.
There was some difference between the Preview and submitting the message because of the way phpBB handles attachments, but it’s working on your forum. Check out my message.
September 30th, 2009 at 9:41 AM
I found your post since your registered and copied your code into a new post to see if it worked with my login.
I’ve also added an attachment of my own that worked.
I swear to god that wasn’t working before you registered/entered my forum site.
I don’t understand what you mean about the previewing. Did you change anything on my site to make that work?
Thanks Loads.
September 30th, 2009 at 9:43 AM
Oh right, I understand what you mean about preview now. I never touch preview I always submit and read and then edit after again if something wrong. So I was defiantly submitting, I’m sure.
I’m baffled to how that works since you registered on my forum site. Perhaps it just needed another user other than myself to kick something off.
I’m going to see if I can change my skin on player and my .flv icon back to what it was intended, then and I shall revisit here to tell you what happened.
September 30th, 2009 at 10:06 AM
Wow it works! Everything is awesome!
Thanks loads for fixing it (still bugging me, a bit, how you fixed it. But I’ll get over that)
September 30th, 2009 at 10:39 AM
Glad it’s working for you. I really didn’t do anything to your site, not that I could.
Here’s exactly what I did:
Made a test post to see the error, which didn’t work in preview
I tried to access the attachment file directly and it said the attachment didn’t exist any more.
I submitted the post and the attachment file directly worked. I then tried the video and it played.
Unfortunately, I don’t know if there’s any easy solution to the attachment directory choice. You might look into official phpbb mods as this could be quite complicated: http://www.phpbb.com/mods/
September 30th, 2009 at 10:47 AM
Thanks. I’m none the wiser.
Thanks. I posted a support post and a mod request there already but nobody replied. I actually posted about this issue as well but nobody replied – So I’m glad you and your site are here. Great job.