Title: BB Code: Windows Media Player v1.0

Author: Ahmad

Description:
This modification will allow you to add media files with these extentions (avi, wmv, mpg) into your posts.
This modification will display a windows media player to control the files.
The default behaviour of the player is off. The file won't start playing until the member clicks Play.

Compatability: 1.9.8 SP3

Bonus :
BB buttons for default XMB board theme
BB buttons for xmbmods.com theme

Install Note: Before adding this modification to your forum you should back up all files related to this modification.

License Note: This modification is released under the GPL License. A copy is provided with this software package.

Author Note:
You downloaded this modification from XMBGarage.com, the #1 source for XMB related downloads.
Please visit http://www.xmbgarage.com/ for support.
=======================================================================================================

=======
Step 1:
=======

===============
Edit functions.php:
===============

=====
Find:
=====

        $patterns[] = "#\[email=([^\"'<>]*?){1}([^\"]*?)\](.*?)\[/email\]#Smi";
        $replacements[] = '<a href="mailto:\1\2">\3</a>';

===========
Add Below:
===========

        // BB Code: Windows Media Player Mod Begin
        $patterns[] = '#\[movie\](http[s]?|ftp[s]?){1}://([:a-z\\./_\-0-9%~]+){1}(\?[a-z=_\-0-9&;~]*)?\[/movie\]#mi';
        $wmplayer   = array();
        $wmplayer[] = '<table border="0" cellpadding="0" align="center">';
        $wmplayer[] = '<tr>';
        $wmplayer[] = '<td><object id="mediaPlayer" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">';
        $wmplayer[] = '<param name="autoStart" value="false" />';
        $wmplayer[] = '<param name="url" value="\1://\2\3" />';
        $wmplayer[] = '<param name="uiMode" value="full" />';
        $wmplayer[] = '<param name="loop" value="false" />';
        $wmplayer[] = '<embed src="\1://\2\3" id="embedMediaPlayer" type="application/x-mplayer2" width="320" height="285"></embed>';
        $wmplayer[] = '</object>';
        $wmplayer[] = '</td></tr>';
        $wmplayer[] = '<tr>';
        $wmplayer[] = '<td align="center"><a href="\1://\2\3" style="font-size: 85%;" target="_blank">'.$GLOBALS['lang']['wmp_launch_external'].'</a></td>';
        $wmplayer[] = '</tr>';
        $wmplayer[] = '</table>';
        $replacements[] = implode('', $wmplayer);
        // BB Code: Windows Media Player Mod End
        
=======================================================================================================

=======
Step 2:
=======

=====================
Edit include/bbcodefns-ie.js:
=====================

======
Find:
======

function storeCaret(textEl) {

===========
Add Above:
===========

// BB Code: Windows Media Player Mod Begin
function movie() {
    if (helpmode) {
        alert(bbcode_help_movie);
    } else if (advmode) {
        AddText('', '', '[movie] [/movie]', messageElement);
    } else {
        txt = prompt(bbcode_prompt_movie, 'http://');
        if (txt != null) {
            AddText('', '', '[movie]'+txt+'[/movie]', messageElement);
        }
    }
}
// BB Code: Windows Media Player Mod End

=======================================================================================================

=======
Step 3:
=======

=========================
Edit include/bbcodefns-mozilla.js:
=========================

======
Find:
======

function storeCaret() {

===========
Add Above:
===========

// BB Code: Windows Media Player Mod Begin
function movie() {
    if(helpmode) {
        alert(bbcode_help_movie);

    } else if(advmode) {
        if(hasSelection(messageElement)) {
            wrapText('[movie]', '[/movie]', messageElement);
        } else {
            AddText('[movie]', '[/movie]', ' ', messageElement);
        }

    } else {
        if(hasSelection(messageElement)) {
            text = prompt(bbcode_prompt_movie, fetchSelection(messageElement));
            if(text == fetchSelection(messageElement)) {
                wrapText('[movie]', '[/movie]', messageElement);
            } else {
                AddText('[movie]', '[/movie]', text, messageElement);
            }
        } else {
            text = prompt(bbcode_prompt_movie, 'Text');
            AddText('[movie]', '[/movie]', text, messageElement);
        }
    }
}
// BB Code: Windows Media Player Mod End

=======================================================================================================

=======
Step 4:
=======

========================
Edit include/bbcodefns-opera.js:
========================

======
Find:
======

function storeCaret(textEl) {

===========
Add Above:
===========

// BB Code: Windows Media Player Mod Begin
function movie() {
      if (helpmode) {
        alert(bbcode_help_movie);
    }else if (advmode) {
        AddText('', '', "[movie] [/movie]", messageElement);

    }else {
        txt=prompt(bbcode_prompt_movie,"Text");
        if (txt!=null) {
            AddText('', '', "[movie]"+txt+"[/movie]", messageElement);
        }
    }
}
// BB Code: Windows Media Player Mod End

=======================================================================================================

=======
Step 4:
=======

==============================
Go to Administration Panel -> Templates:
==============================

========================
Edit template functions_bbcode
========================

======
Find:
======

var bbcode_help_code = "$lang[bbcode_help_code]";
var bbcode_prompt_code = "$lang[bbcode_prompt_code]";

===========
Add Below:
===========

var bbcode_help_movie = "$lang[bbcode_help_movie]";
var bbcode_prompt_movie = "$lang[bbcode_prompt_movie]";

=======================================================================================================

=======
Step 5:
=======

==============================
Go to Administration Panel -> Templates:
==============================

===========================
Edit template functions_bbcodeinsert
===========================

=====
Find:
=====

<a href="javascript:list()"><img src="$imgdir/bb_list.gif" border="0" width="23" height="22" alt="$lang[cb_insert_list]"></a></td>

============
Replace With:
============

<a href="javascript:list()"><img src="$imgdir/bb_list.gif" border="0" width="23" height="22" alt="$lang[cb_insert_list]"></a>
<a href="javascript:movie()"><img src="$THEME[imgdir]/bb_movie.gif" border="0" width="23" height="22" alt="$lang[cb_insert_movie]"></a></td>

=======================================================================================================

=======
Step 6:
=======

================
Edit English.lang.php
================

=======================
Add To End Of File Above ?>
=======================

// BB Code: Windows Media Player Mod Begin
$lang['bbcode_prompt_movie'] = "Please enter the URL for the Movie file ( wmv, avi, mpg )";
$lang['bbcode_help_movie'] = "Movie Tag\\nInserts a Movie file into the post. Usage: [movie]http://www.anywhere.com/file.wmv[/movie]";
$lang['cb_insert_movie'] = "Insert a Windows Media Video Movie";
$lang['wmp_launch_external'] = "Launch In External Player";
// BB Code: Windows Media Player Mod End

=======================================================================================================

Upload bb_movie.gif from the 'Contents' folder to all your theme directories.

=======================================================================================================
Enjoy!