PDA

View Full Version : Playing Windows Media Files Inline


Moya
09-16-2005, 10:00 PM
This just a port over from my existing hack for version 3.0.x

https://vborg.vbsupport.ru/showthread.php?t=78235


What this hack does::

This hack allows your users to upload media files via your board file management and play the media fields within their post.. It is adivisable to have one inline per post.


Foreword:

This hack might not work on all system due to different configuration, platform, and such. I will try to help you all as much as I can.

This hack will use your board attachment system to run mp3, wma, wmv, flash files. It is a bit server intensive. So be warned

Security Risk:

It has been known that flash files can be used to exploit and compromise certain securities on user computer. You might want to verify your flash attachment before enable flash playing inline on your forum.

Files To edit: 1
Queries to run: 0
Uses Product: Yes
Template Edits: 2

File Edit

includes/class_postbit.php


Find

function process_attachments()
{
global $stylevar, $show, $vbphrase;



Add under


// flash attachment
global $flashid,$flashfilename,$flashextension,$flashfile nameandlocation,$flashfilesize ;

// wma attachment
global $wmaid,$wmafilename,$wmaextension,$wmafilenameandl ocation,$wmafilesize;
// wmv attachment
global $wmvid,$wmvfilename,$wmvextension,$wmvfilenameandl ocation,$wmvfilesize;
// mp3 attachment
global $mp3id,$mp3filename,$mp3extension,$mp3filenameandl ocation,$mp3filesize;
//default media tag
$media_controller= "attachment.php?". $this->registry->session->vars['sessionurl'] ."attachmentid=";




Look for



$attachment['attachmentextension'] = strtolower(file_extension($attachment['filename']));
$attachment['filesize'] = vb_number_format($attachment['filesize'], 1, true);



Add Under


//start Play inline
//flash attachment
$flashfilename=$attachment['filename'];
$flashextension=$attachment['attachmentextension'];
$flashfilesize=$attachment['filesize'];
$flashid=$post['userid'];
$flashfilenameandlocation=$media_controller . $attachmentid ;
//wma attachment
$wmaid=$post['userid'];
$wmafilename=$attachment['filename'];
$wmaextension=$attachment['attachmentextension'];
$wmafilenameandlocation=$media_controller . $attachmentid ;
$wmafilesize=$attachment['filesize'];
//wmv attachment
$wmvid=$post['userid'];
$wmvfilename=$attachment['filename'];
$wmvextension=$attachment['attachmentextension'];
$wmvfilenameandlocation=$media_controller . $attachmentid ;
$wmvfilesize=$attachment['filesize'];
//wmv attachment
$mp3id=$post['userid'];
$mp3filename=$attachment['filename'];
$mp3extension=$attachment['attachmentextension'];
$mp3filenameandlocation=$media_controller . $attachmentid ;
$mp3filesize=$attachment['filesize'];
//end play inline





else
{
eval('$this->post[\'imageattachmentlinks\'] .= "' . fetch_template('postbit_attachment') . '";');
$show['imageattachmentlink'] = true;
}
break;




Add Undder



case 'swf':
eval('$this->post[\'flashattachments\'] .= "' . fetch_template('postbit_attachmentflash') . '";');
$show['flashattachment'] = true;
break;

case 'wma':
eval('$this->post[\'wmaattachments\'] .= "' . fetch_template('postbit_attachmentwma') . '";');
$show['wmaattachment'] = true;
break;

case 'wmv':
eval('$this->post[\'wmvattachments\'] .= "' . fetch_template('postbit_attachmentwmv') . '";');
$show['wmvattachment'] = true;
break;

case 'mp3':
eval('$this->post[\'mp3attachments\'] .= "' . fetch_template('postbit_attachmentmp3') . '";');
$show['mp3attachment'] = true;
break;




Template Edit

Postbit template

Look for


$post[imageattachments]
</div>
</fieldset>
</if>



Add Under



<if condition="$show[flashattachment]">
<fieldset class="fieldset">
<legend>$vbphrase[attached_flash] $flashfilename </legend>

<div style="padding:$stylevar[formspacer]px">
$post[flashattachments]
</div>
</fieldset>

</if>



<if condition="$show[wmaattachment]">
<fieldset class="fieldset">
<legend>$vbphrase[attach_wma] $wmafilename</legend>

<div style="padding:$stylevar[formspacer]px">
$post[wmaattachments]
</div>
</fieldset>

</if>

<if condition="$show[wmvattachment]">
<fieldset class="fieldset">
<legend>$vbphrase[attach_wmv] $wmvfilename</legend>

<div style="padding:$stylevar[formspacer]px">
$post[wmvattachments]



</div>
</fieldset>

</if>

<if condition="$show[mp3attachment]">
<fieldset class="fieldset">
<legend>

$vbphrase[attach_mp3] $mp3filename</legend>

<div style="padding:$stylevar[formspacer]px">
$post[mp3attachments]

</div>
</fieldset>

</if>



Postbit legacy template

Look for


$post[imageattachments]
</div>
</fieldset>
</if>



Add Under



<if condition="$show[flashattachment]">
<fieldset class="fieldset">
<legend>$vbphrase[attached_flash] $flashfilename </legend>

<div style="padding:$stylevar[formspacer]px">
$post[flashattachments]
</div>
</fieldset>

</if>



<if condition="$show[wmaattachment]">
<fieldset class="fieldset">
<legend>$vbphrase[attach_wma] $wmafilename</legend>

<div style="padding:$stylevar[formspacer]px">
$post[wmaattachments]
</div>
</fieldset>

</if>

<if condition="$show[wmvattachment]">
<fieldset class="fieldset">
<legend>$vbphrase[attach_wmv] $wmvfilename</legend>

<div style="padding:$stylevar[formspacer]px">
$post[wmvattachments]



</div>
</fieldset>

</if>

<if condition="$show[mp3attachment]">
<fieldset class="fieldset">
<legend>

$vbphrase[attach_mp3] $mp3filename</legend>

<div style="padding:$stylevar[formspacer]px">
$post[mp3attachments]

</div>
</fieldset>

</if>



Upload the included XML as product.



Demo

https://vborg.vbsupport.ru/external/2005/11/1.php?attachmentid=24797

https://vborg.vbsupport.ru/external/2005/11/1.php?attachmentid=24798

https://vborg.vbsupport.ru/external/2005/11/1.php?attachmentid=24799

https://vborg.vbsupport.ru/external/2005/11/1.php?attachmentid=24800



If you use this hack please click install.

lttcoder
09-17-2005, 10:21 AM
Sounds great, but I won't install it since it requires template changes/file changes.

COBRAws
09-17-2005, 10:43 AM
going to make some good use out of this one! Thank you pal.

FleaBag
09-17-2005, 02:27 PM
Sounds great, but I won't install it since it requires template changes/file changes.

Refusing to make template changes is a bit extreme... You're going to miss out on a lot of great hacks.

Anyway, can't this be done using BB Code?

Gizmo5h1t3
09-17-2005, 02:28 PM
cant seem to get this working on rc2...

the product list doesnt show this as installed or active, when its been installed...and theres nothing in the postbit, or postbit legacy style to show its installed...

Gizmo5h1t3
09-17-2005, 02:34 PM
Refusing to make template changes is a bit extreme... You're going to miss out on a lot of great hacks.

Anyway, can't this be done using BB Code?

if i remember right, this was done on 3.0.7 with BB code...

if i remember right...

hydrostatic
09-17-2005, 02:58 PM
Refusing to make template changes is a bit extreme... You're going to miss out on a lot of great hacks.

Anyway, can't this be done using BB Code?

It's just that I don't want to do file edits... I don't care about template edits because I don't have to reapply them every time.

Anyway, I'd love this hack if it can be done without file edits.

Marco van Herwaarden
09-17-2005, 04:55 PM
Refusing to make template changes is a bit extreme... You're going to miss out on a lot of great hacks.Not always true. If you look at some of my 3.5 hacks, you will see that i do the template edits during runtime. No manual editing needed.
I don't care about template edits because I don't have to reapply them every time.
If you look at the 3.5 releases until now, you will see that most needed one or more templates to be reverted. With all the new AJAX this will only happen more.

Moya
09-17-2005, 05:33 PM
cant seem to get this working on rc2...

the product list doesnt show this as installed or active, when its been installed...and theres nothing in the postbit, or postbit legacy style to show its installed...

Hi Gizmo

I haven't test this out on RC2.

Andreas
09-19-2005, 09:06 AM
It's a bit tricky, but I think it would be possible to do this without File Edits.

Moya
09-19-2005, 07:32 PM
It's a bit tricky, but I think it would be possible to do this without File Edits.


I always wonder about this new feature of VB3.5, but I don't know where to begin. It would be good if we can have certain guide line

jesus likes pie
09-19-2005, 08:23 PM
LOVE IT....but file edits :(

If only you could make it use plugins....I might still consider it once we go 3.5 gold....or 3.5.1.

Gizmo5h1t3
10-02-2005, 01:36 PM
getting this db error when i install the product...
Database error in vBulletin 3.5.0:

Invalid SQL:

INSERT INTO product
(productid, title, description, version, active, apm_releasedate, apm_author, apm_relatedurl, apm_extrainfo, apm_extraedit)
VALUES
('media_inline',
'Playing Media Files Inline',
'Display media files within posts and threads',
'1.0.1',
1,
'',
'',
'',
'',
''
);

MySQL Error : Unknown column 'apm_releasedate' in 'field list'
Error Number : 1054
Date : Sunday, October 2nd 2005 @ 03:33:38 PM

any ideas guys??

Gizmo5h1t3
10-16-2005, 10:21 AM
just as an addition to this, the sql error was sorted, it was my fault...lol

BUT....nothing shows up on the board saying its working...

where are you supposed to look, or is there something that has to be activated for it to work at all?
im using 3.5 GOLD btw

turkboard
10-17-2005, 07:23 PM
3.5 GOLD work ?

tamborinegal
10-20-2005, 02:32 AM
Does this work for 3.5 Gold? Would love it if it did :)

Thanks

davidw
10-21-2005, 08:09 PM
I just installed this, and I have 3.5.0 Gold.
However, it needs to be mentioned that as it is, it will NOT work, without one more modification which was not mentioned.

In ACP, go to Extensions & Sizes. Click Add New Attachment Type.
(you must do this for each file type - mp3 is given as an example)
************************************************** **********
Extension: mp3
Max Filesize(in bytes) 5000000
Mime Type: Content-type: audio/mp3
Display thumbnail for this type? No
Open this attachment in a new browser window? No (Really this is your choice)
Enabled Yes
************************************************** **********
For a temporary demo, click here (http://www.christianboards.org/showthread.php?p=2000&posted=1#post2000)

davidw
10-21-2005, 09:01 PM
I've also made edits to include wav if anyone is interested.

http://www.christianboards.org/showthread.php?t=409
For a limited time only.

cbr929rrerion
10-31-2005, 06:04 PM
I want this to play avi, mva, mpeg, basic video files, I have 3.5, I tried it and all I get is a link.... any suggestions?

cbr929rrerion
10-31-2005, 07:44 PM
I get this with, avi, mov, and mpg, all formats...

davidw
10-31-2005, 07:59 PM
I'm working on it at the moment as I don't have avi set up yet - testing to make sure it works - did you edit the xml file? This launches the player.

cbr929rrerion
10-31-2005, 08:10 PM
I am not very good at that..

If anyone can get avi and mpg and wvm to work I would love it..

davidw
10-31-2005, 08:19 PM
Ok here's the sample: http://www.christianboards.org/showthread.php?p=2252#post2252

davidw
10-31-2005, 08:26 PM
Here's the instructions on how I did it...

I'm using this loosely for avi as examples on how to edit; replace with the appropriate file type

In your class_postbit.php file

Find:

// wma attachment
global $wmaid,$wmafilename,$wmaextension,$wmafilenameandl ocation,$wmafilesize;

Add after:

// avi attachment
global $aviid,$avifilename,$aviextension,$aviafilenameand location,$avifilesize; (replacing wma with avi in each)

Find:

//wma attachment
$wmaid=$post['userid'];
$wmafilename=$attachment['filename'];
$wmaextension=$attachment['attachmentextension'];
$wmafilenameandlocation=$media_controller . $attachmentid ;
$wmafilesize=$attachment['filesize'];


Add after:

//avi attachment
$aviid=$post['userid'];
$avifilename=$attachment['filename'];
$aviextension=$attachment['attachmentextension'];
$avifilenameandlocation=$media_controller . $attachmentid ;
$avifilesize=$attachment['filesize'];(replacing wma with avi in each)

Find:

case 'wma':
eval('$this->post[\'wmaattachments\'] .= "' . fetch_template('postbit_attachmentwma') . '";');
$show['wmaattachment'] = true;
break;


Add after:

case 'avi':
eval('$this->post[\'aviattachments\'] .= "' . fetch_template('postbit_attachmentavi') . '";');
$show['aviattachment'] = true;
break;
(replacing wma with avi in each)

Postbit template edit (I use postbit legacy, you'll have to compare to postbit for the changes)

Find:

<if condition="$show[wmaattachment]">
<fieldset class="fieldset">
<legend>$vbphrase[attach_wma] $wmafilename</legend>

<div style="padding:$stylevar[formspacer]px">
$post[wmaattachments]
</div>
</fieldset>

</if>

Add after:

<if condition="$show[aviattachment]">
<fieldset class="fieldset">
<legend>$vbphrase[attach_avi] $avifilename</legend>

<div style="padding:$stylevar[formspacer]px">
$post[aviattachments]
</div>
</fieldset>

</if>(replacing wma with avi in each)


ADMINCP - Attachments - Extensions & Sizes - Add New Extension

Extension: avi
Max Filesize(in bytes) 5000000 (or whatever you want
Mime Type: Content-type: video/x-ms-avi
Display thumbnail for this type? No
Open this attachment in a new browser window? No (Really this is your choice)
Enabled Yes

XML edit

Add this after one of your templates: (It will end in </template>)
<template name="postbit_attachmentavi" templatetype="template" date="1125000000" username="christianb" version="3.5.0">
<![CDATA[
<br>
<center>
<table border="0" align="center" width="400" cellspacing="0" cellpadding="0" height="275">
<tr>
<td class="thead" width="100%" height="25">
<center>
<font color="#FFFFFF">
AVI Attachment
</font>
</center>
</td>
</tr>
<tr>
<td width="100%" height="225">
<center>
<object classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" id="Player" width="400" height="225"
codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,0,0" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">

<param name="URL" value="$avifilenameandlocation">
<param name="rate" value="1">
<param name="balance" value="0">
<param name="currentPosition" value="1">
<param name="defaultFrame" value>
<param name="playCount" value="1">
<param name="autoStart" value="-1">
<param name="loop" value="-1">
<param name="currentMarker" value="0">
<param name="invokeURLs" value="-1">
<param name="baseURL" value>
<param name="volume" value="200">
<param name="mute" value="0">
<param name="uiMode" value="full">
<param name="stretchToFit" value="0">
<param name="windowlessVideo" value="0">
<param name="enabled" value="-1">
<param name="enableContextMenu" value="0">
<param name="fullScreen" value="0">
<param name="SAMIStyle" value>
<param name="SAMILang" value>
<param name="SAMIFilename" value>
<param name="captioningID" value>
<param name="enableErrorDialogs" value="0">
<param name="_cx" value="7938">
<param name="_cy" value="6482">

<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/windows95/downloads/contents/wurecommended/s_wufeatured/mediaplayer/default.asp" src="$wmafilenameandlocation"
rate=1
balance=0
currentPosition=1
playCount=1
autoStart=1
loop=-1
currentMarker=0
invokeURLs=-1
volume=200
mute=0
uiMode=full
stretchToFit=0
windowlessVideo=0
enabled=-1
enableContextMenu=0
fullScreen=0
SAMIStyle
SAMILang
SAMIFilename
captioningID
enableErrorDialogs=0
_cx=7938
_cy=6482
width=400
height=225>
</embed>
</object>
</center>
</td>
</tr>
<tr>
<td class="thead" width="100%" height="25">
<center>
<font color="#6600FF">
<a href="attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]" target="_blank">$attachment[filename]</a> <span class="smallfont">($attachment[filesize] bytes, $attachment[counter] views)</span>
</font>
</center>
</td>
</tr>

</table>
</center>
<br>
]]>
</template>

Don't forget to update your phrase manager:

Add New Phrase

Phrase Type: Global
Varname: attach_avi
Text: AVI (doesn't really matter - shows up in your legend)

AdamMarrer
11-01-2005, 04:04 AM
After making these changes I can't upload these two file formats, after upload is done it just rests the screen never showing the attachments. Any ideas?

davidw
11-01-2005, 09:39 AM
wmv was part of the default code, you shouldn't have had to change anything for that file format.

cbr929rrerion
11-01-2005, 11:59 AM
th default code did not work.. all that was displayed was a ling to it, still had to click and download it.. any ideas where its wrong?

davidw
11-01-2005, 12:37 PM
Have you checked your message attachment options in AdminCP?

vBulletin Options -> Message Attachment Options

View Attached Images Inline - Yes or Yes, if post has only one attachment

Also, are your attachments currently being stored in the filesystem or database? Not sure, but this might make a difference.

cbr929rrerion
11-01-2005, 01:51 PM
yes show attachements and file system..

davidw
11-01-2005, 04:04 PM
The only thing I can think of is to uninstall it - make the changes - reinstall it.
I don't understand why it wouldn't work on your site, as it does work on mine - unless there's another setting I've overlooked.

Moya
11-01-2005, 10:29 PM
Hello All,

Since we move to VB3.5 Gold, I moved this hack to use Plugin. You don't have to do file editing anymore.

I will stop supporting this version. Please come Come To This Hack In Plug In Here (https://vborg.vbsupport.ru/showthread.php?t=99871)


Thanks