WMPlayer
Questions answered by this recipe
How can I play windows media files from within wiki pages?
How can I embed Windows Media Player?
Description
Download wmplayer.phpΔ, copy to cookbook/ and install by adding to config.php:
include_once("$FarmD/cookbook/wmplayer.php");
This adds the directive (:wmplayer file parameters... :)
to associate media files with the player.
Syntax
(:wmplayer Attach:filename.ext width=number height=number [key=value] [key=value] ... :)
- use
Attach:filename
orhttp://urlpath/filepath/filename
- height= and width= parameters are mandatory
- other parameters can be supplied to control the player's behaviour
- Example (music):
(:wmplayer Attach:mymusic.wma width=200 height=25 :)
- Example (video):
(:wmplayer Attach:myvideo.wmv width=320 height=240 :)
- You can use any other media formats the player supports. You may need to add more formats to the formats uploads allow.
- External fileurls of form
http://....
can be used. - Setting
$EnableExternalResource = 0;
will disable the use ofhttp://...
fileurls.
Notes
This recipe won't work after PHP verion 5.4. Instead try Ape.
You may wish to add wma, wmv, or other extensions to be allowed for file uploads. Add to config.php:
$UploadExts['wma'] = 'audio/wma'; $UploadExts['wmv'] = 'video/wmv'; $UploadExts['mid'] = 'video/wmv'; $UploadExts['midi'] = 'video/wmv';
I had not much luck with the following long list of parameters. The ones which worked were:
- autostart=false -- default is true
- playcount=nn
Most important parameters supported by Windows Media Player 7 and later:
Parameter | Default | Description |
autoStart | true | Specifies or retrieves a value indicating whether the current media item begins playing automatically. |
balance | 0 | Specifies the current stereo balance. Values range from 100 to 100. |
baseURL | Specifies the base URL used for relative path resolution with URL script commands that are embedded in media items. | |
captioningID | 0 | Specifies the name of the element displaying the captioning. |
currentMarker | 0 | Specifies the current marker number. |
currentPosition | 0 | Specifies the current position in the media item in seconds. |
defaultFrame | - | Specifies the name of the frame used to display a URL. |
enableContextMenu | true | Specifies a value indicating whether to enable the context menu, which appears when the right mouse button is clicked. |
enabled | false | Specifies whether the Windows Media Player control is enabled. |
fullScreen | false | Specifies whether video content is played back in full-screen mode. |
InvokeURLs | true | Specifies a value indicating whether URL events should launch a Web browser. |
Mute | false | Specifies if audio is muted. |
PlayCount | 1 | Specifies the number of times a media item will play. Minimum value of one. |
Rate | 1.0 | Specifies the playback rate. 0.5 equates to half the normal playback speed, 2 equates to twice. |
stretchToFit | false | Specifies whether video displayed by the control automatically sizes to fit the video window, when the video window is larger than the dimensions of the video image. |
uiMode | full | Specifies which controls are shown in the user interface. Possible values: invisible, none, mini, full. |
URL | - | Specifies the name of the media item to play. You can specify a local filename or a URL. |
Volume | Last setting | Zero specifies no volume and 100 specifies full volume. |
windowlessVideo | false | Specifies or retrieves a value indicating whether the Windows Media Player control renders video in windowless mode. When windowlessVideo is set to true, the Player control renders video directly in the client area, so you can apply special effects or layer the video with text. Supported by Windows Media Player for Windows XP or later. |
More info: Windows Media Player PARAM tags
Release Notes
- 2006-04-13: added type declaration to code
- 2006-03-10: initial release. The code is modified from Schlaefer's QuickTime recipe.
Comments
I've hacked together a version of this script which uses <embed> and also works under Firefox, although not all the options are configurable. If there's anywhere I can post it, just let me know. Paul C - 19/9/2007 - www.paulcull.org
Would it be possible for someone to make a recipe which embed media with the <embed src="file.ext" autostart="..." width="..." height="..." ...> syntax, in order for more compatible pages. e.g. with linux?
-- tlucas
- 2008-03-24
I've modified the script by Paul C. which uses <object> and also works under Firefox. The syntax is now a little bit different:
Download wmplayer2.phpΔ, rename to wmplayer.php, copy to cookbook/ and install by adding to config.php:
include_once("$FarmD/cookbook/wmplayer.php");
This adds the directive (:wmplayer Attach:filename type=MIME-Type width=number height=number:)
- Example (music):
(:wmplayer Attach:mymusic.wma type=audio/x-ms-wma width=320 height=45:)
- Example (video):
(:wmplayer Attach:myvideo.wmv type=video/x-ms-wmv width=320 height=285:)
Casiopeia
wmplayer2
worked well for me with Windows on Firefox 3 (and IE7), but not Opera.
Denis
2010-01-24 Where can I find/modify the source directory of the media files used in the 'attach' parameter ?
See Also
- Ape: Automagical PmWiki Embed Embed videos, maps, documents, and more in wiki pages
- QuickTime Embed QuickTime content on wiki sites.
- Embedding the Windows Media Player (webreference tutorial)
Contributors
User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.