Media Player Object Plugin

Description

The Media Player object plugin allows you to display any Windows Media Player-compatible file format (including MPEG and WMV files) on the page. It does this by taking advantage of the Windows Media Player ActiveX control that is found on most systems.

Specifically, it embeds this Windows Media Player control directly into your application. This essentially "borrows" Windows Media Player and uses it to display media files in your application.

Note: You can detect whether or not the Media Player ActiveX control is installed at run time using the Dependecies feature of AutoPlay Media Studio (see Project > Dependencies).

Note: Due to a limitation in Windows NT 4.0, a video's audio track will only be heard if the AutoPlay Media Studio audio engine is disabled. You can disable the audio engine on Windows NT 4.0 by choosing Project > Settings from the menu, selecting the Advanced tab and checking the Disable Audio Engine option. For further information, see "Disable Audio Engine" in the AutoPlay Media Studio command reference.

Important Information

Please note that there are many different versions of the Windows Media Player ActiveX control. Some versions of the control do not look and operate the same as previous versions. In creating this plugin we have tried to maintain compatibility for versions 6.4-9.0 of the ActiveX control. However, you should be aware that there can be many potential issues when using any third-party ActiveX control, especially the Windows Media Player control. Therefore we strongly recommend that you test any projects that use this plugin thoroughly and use the plugin at your own risk.

Properties

Automatically start playing on load

If checked, the object will automatically start playing media files that are loaded using MediaPlayer.Load.

Show transport controls

If checked, the transport controls will be displayed at run time. These controls include play, pause, stop buttons as well as volume, status and slider controls.

Automatically rewind when clip is stopped

If checked, the media will rewind to the beginning of the clip when the stop button is pressed or the MediaPlayer.Stop action is executed.

Show context menu

If checked, the default Media Player context menu will be displayed if the user right-clicks the mouse on the video window. If uncheckd, no context menu will appear.

Events

On Play

Fires when a media clip starts playing or continues playing in response to the user clicking the play button, a MediaPlayer.Play action being executed or if a clip is loaded and the "Automatically start playing on load" setting is turned on.

On Pause

Fires when a media clip pauses in response to the user clicking the pause button or a MediaPlayer.Pause action being executed.

On Stop

Fires when a media clip stops in response to the user clicking the stop button, a MediaPlayer.stop action being executed or the end of the clip being reached.

On Finish

Fires when a media clip reaches the end of the stream during playback.

Actions

In addition to the generic "Plugin" actions supported by all plugin objects, the Media Player plugin also supports the following actions:

number MediaPlayer.GetCurrentPos (string ObjectName);

Description:

Gets the current playback position (in seconds) of a Media Player object.

ObjectName:

(string) The name of the Media Player object that you want to apply this action to.

Returns:

(number) The current playback position of the Media Player object, in seconds.

Example:

-- Get the current playback position and the total clip length
-- and display the information in a label object. This could be
-- done on a page's "On Timer" event to display playback progress
local length = MediaPlayer.GetLength("media_player");
local pos = MediaPlayer.GetCurrentPos("media_player");
local msg = string.format("%.2f/%.2f",pos,length);
Label.SetText("time",msg);

number MediaPlayer.GetLength (string ObjectName);

Description:

Gets the length of the currently loaded media (in seconds) of a Media Player object.

ObjectName:

(string) The name of the Media Player object that you want to apply this action to.

Returns:

(number) The length of the currently loaded media, in seconds.

Example:

-- Get the current playback position and the total clip length
-- and display the information in a label object. This could be
-- done on a page's "On Timer" event to display playback progress
local length = MediaPlayer.GetLength("media_player");
local pos = MediaPlayer.GetCurrentPos("media_player");
local msg = string.format("%.2f/%.2f",pos,length);
Label.SetText("time",msg);

number MediaPlayer.GetState (string ObjectName);

Description:

Gets the current state of a Media Player object.

ObjectName:

(string) The name of the Media Player object that you want to apply this action to.

Returns:

(number) The state of the Media Player object:

VIDEO_STOPPED (0) - Stopped.
VIDEO_PAUSED (1) - Paused.
VIDEO_PLAYING (2) - Playing.

Example:

-- This script could be put onto a play/pause toggle button's On Click 
-- event in order to toggle the text on the button
if((MediaPlayer.GetState("media_player") == VIDEO_PAUSED) or (MediaPlayer.GetState("media_player") == VIDEO_STOPPED))then
    MediaPlayer.Play("media_player");
    Button.SetText("ButtonPlay", "PAUSE");
else
    MediaPlayer.Pause("media_player");
    Button.SetText("ButtonPlay", "PLAY");
end

number MediaPlayer.GetVolume (string ObjectName);

Description:

Gets the volume of a Media Player object.

Note: This action does not work reliably with the Media Player 6.4 ActiveX control, but it works fine with the Media Player 9.0+ control.

ObjectName:

(string) The name of the Media Player object that you want to apply this action to.

Returns:

(number) The current volume of the Media Player object. 0 means silent, 100 is maximum volume.

Example:

-- Get the current volume level of a Media Player object
nVolume = MediaPlayer.GetVolume("media_player");

MediaPlayer.Load (string ObjectName, string Filename);

Description:

Loads a media file into a Media Player object.

ObjectName:

(string) The name of the Media Player object that you want to apply this action to.

Filename:

(string) The fully qualified path and filename of the media file to load.

Returns:

Nothing.

Example:

-- Display a File Browse Dialog, and then play the video that they select    

-- Pick a nice default folder to start the browsing in (My Documents)    
myfolder = Shell.GetFolder(SHF_MYDOCUMENTS);    

-- Show the file browse dialog    
strExtensions = "All Video Files (*.avi;*.mpg;*.wmv;*.asf)|*.avi;*.mpg;*.wmv;*.asf|All Files (*.*)|*.*|";    
tFiles = Dialog.FileBrowse(true, "Load Video", myfolder, strExtensions, "", "", false, true);    

-- Only load the video if they did not press Cancel    
if tFiles[1] ~= "CANCEL" then    
    -- make sure the object is visible before trying to load a video    
    Plugin.SetVisible("media_player", true);    
	    
    -- Load the video File    
    MediaPlayer.Load("media_player",tFiles[1]);    
    
    -- Play the video    
    Video.Play("Video1");    
end    

MediaPlayer.Pause (string ObjectName);

Description:

Pauses the playback of a Media Player object.

ObjectName:

(string) The name of the Media Player object that you want to apply this action to.

Returns:

Nothing.

Example:

-- Pause playback in a Media Player object
MediaPlayer.Pause("media_player");

MediaPlayer.Play (string ObjectName);

Description:

Starts the playback of a Media Player object.

ObjectName:

(string) The name of the Media Player object that you want to apply this action to.

Returns:

Nothing.

Example:

-- Start playback in a Media Player object
MediaPlayer.Play("media_player");

MediaPlayer.Seek (string ObjectName, number SeekType, number SeekTime = 0);

Description:

Seeks to a position in a media clip that is loaded in a Media Player object.

ObjectName:

(string) The name of the Media Player object that you want to apply this action to.

SeekType:

(number) The type of seek to perform:

SEEK_BEGINNING (0) - Seek to the beginning of the current track.
SEEK_END (1) - Seek to the end of the current track.
SEEK_FORWARD (2) - Seek forward.
SEEK_BACKWARD (3) - Seek backward.
SEEK_SPECIFIC (4) - Seek to a specific time within the track.

SeekTime:

(number) The time in seconds to seek to (or seek by). Defaults to 0.

Note: SeekTime is only used if SeekType is 2, 3 or 4.

Returns:

Nothing.

Example:

-- Rewind the media clip    
MediaPlayer.Seek("media_player", SEEK_BEGINNING);    

-- Seek forward seven and one half seconds    
MediaPlayer.Seek("media_player", SEEK_FORWARD, 7.5);    

-- Seek to fifteen seconds into the clip    
MediaPlayer.Seek("media_player", SEEK_SPECIFIC, 15);    

MediaPlayer.SetFullScreen (string ObjectName, boolean Fullscreen);

Description:

Controls whether a Media Player object will play in full screen mode or at its normal size.

ObjectName:

(string) The name of the Media Player object that you want to apply this action to.

Fullscreen:

(boolean) Whether the Media Player window should go to full screen mode. If true, the Media Player window will go to full screen mode (if it isn't already full screen). If false, it will return to normal size (if it isn't already normal).

Note: For Windows Media Player 9.0+ you must call this action after loading your media file. Calling this action before you load your media file will have no effect.

Returns:

Nothing.

Example:

-- Make the Media Player object go full screen
MediaPlayer.SetFullScreen("media_player", true);

MediaPlayer.SetVolume (string ObjectName, number Volume);

Description:

Sets the volume level of a Media Player object. The volume can range from 0 (silent) to 100 (full).

Note: This action does not work reliably with the Media Player 6.4 ActiveX control, but it works fine with the Media Player 9.0+ control.

ObjectName:

(string) The name of the Media Player object that you want to apply this action to.

Volume:

(number) The volume level to set (0-100).

Returns:

Nothing.

Example:

-- Set the volume to 50%
MediaPlayer.SetVolume("media_player", 127);

MediaPlayer.Stop (string ObjectName);

Description:

Stops the playback of a Media Player object.

ObjectName:

(string) The name of the Media Player object that you want to apply this action to.

Returns:

Nothing.

Example:

-- Stop the playback in a Media Player object
MediaPlayer.Stop("media_player");

Error Codes

1100 - Could not find the specified plugin object or the plugin object is of the wrong type.

Change Log

1.0.1.0

1.0.0.6

1.0.0.5

1.0.0.4

Additional Information

Author:

Indigo Rose Corporation
support.indigorose.com

Copyright:

The Media Player Plugin Object is copyright © 2003-2005 Indigo Rose Software Design Corporation.

Website:

http://www.indigorose.com

Media Player:

http://www.microsoft.com/windows/windowsmedia


Copyright © 2003-2005 Indigo Rose Software Design Corporation.
All Rights Reserved.