Overview
The mediaPlay ActiveX control allows captures to be placed on a web server and viewed across a local intranet or the Internet.
Implementation
By using a mixture of JavaScript and HTML the ActiveX control can be embedded in a page and integrated into existing web sites.
Use the following code to embed the control into a web page.
<object id="my_name"
classid="CLSID:00E5C12B-D2DC-4589-8462-49CB4B83C42E"
width=640
height=480
codebase="my_url_address/mediaplay.cab#Version=-1,-1,-1,-1>
<param name="Toolbar" VALUE=0>
<param name="InWebBrowser" value=1>
</object>
Visit our demo section for examples of how to embed the control into your own HTML. You are free to copy and alter the code to use it in your own websites.
Our demo examples are a little more complex as they automatically detects if the ActiveX control is present on your machine, if it isn't then your are taken to a separate download page explaining about our mediaPlay ActiveX control and giving you the choice to download it.
Auto downloading
If you wish to make the control download you will require the codebase parameter to be set correctly. It should be a full URL pointing to a .cab file on your network or server. It allows downloading and installation of the activeX control if either no version of control is installed on a user's computer or if no appropriate version of control is installed.
Setting #Version=-1,-1,-1,-1 causes the control to be downloaded from the server if the release date is later than the installation date on the client computer.
To download a certain version of the control set #Version=a,b,c,d:
a = High-order word of the major version of the component.
b = Low-order word of the major version of the component.
c = High-order word of the minor version of the component.
d = Low-order word of the minor version of the component.
i.e. #Version=2,7,3,4
If you would like the user to be prompted before downloading the control then you will require a small amount of JavaScript to be added to your web page.
The JavaScript tests to see if you have a control already loaded, this is done by simply calling a function within the control object, if the function fails then the control is out of date or not available. To stop the user being warned about an error on the page the test of the control is done within a try, catch exception handler.
var bControlLoaded = 0;
var testID = 0;
function test_control()
{
if (bControlLoaded)
return 1;
try
{
var p = document.getElementById(
"my_name" );
if (p)
{
p.GetData( 1 );
}
}
catch (err)
{
return 0;
}
bControlLoaded = 1;
return 1;
}
You can now call test_control() from and take the user to another page informing them that they require a control to be installed.
function auto_load()
{
if (!test_control())
{
// jump to the download page
document.location.href = "download_page.htm";
}
}
Now insert the auto_load() function in your body onLoad
i.e <body onLoad="auto_load();">
You now have the code to jump to a new download page if the control isn't available.
Download page
On the download page you can display details about the control
and a button for downloading and installing.
To download the control on demand you must create it dynamically.
This can be done by placing a span or div tag within your
html to allow a control to be inserted.
<span id='insert_mediaPlay'></span>
The following function will create an object to automatically
download the control.
function insert_control()
{
document.getElementById("insert_mediaPlay").innerHTML
=
'<object id="my_name" classid="CLSID:00E5C12B-D2DC-4589-8462-49CB4B83C42E"
'
+ ' WIDTH=1 HEIGHT=1 codebase="my_url_address/mediaplay.cab#Version=2,7,3,4">'
+ '<param name="InWebBrowser=1>'
+ '<PARAM NAME="Toolbar" VALUE=0>'
+ '</object>';
}
Simply call the insert function from your button and the control will be downloaded.
If you wish the browser to return to your last page once the control is installed then you will need to test to see if the control is available by calling the test_control() function until it returns 1. To automate the process you will need to use a timer. Add the following line at the end of the the insert_control() function.
testID = window.setInterval("test_downloadl();", 2000);
Now create a new function to test the download, when complete it will display a popup box with the version number of the control, then take the browser back to the last page.
function test_download()
{
if(test_control() && testID)
{
var n = document.getElementById(
"my_name").getData( 1 ).toString();
var str = n.substr( 0, 1 ) + ","
+ n.substr( 1, 1 ) + "," +
n.substr( 2, 1 ) + "," + n.substr( 3, 1 );
alert( "Installed mediaPlay version
" + str );
history.back();
window.clearInterval(testID);
}
}
Sizing the control
You can size the control when you first create it by setting
the WIDTH and HEIGHT parameters of the object.
You can also size the control by using the following code, if
the toolbar is set then the height of the control needs to be
adjusted.
function size_control( w, h )
{
var p = document.getElementById( "my_name");
if (p)
{
if (p.ToolBar)
h += 28;
p.width = w;
p.height = h;
}
}
Source
Download a zip of the source.
Cabinet Files (.CAB)
The Microsoft cabinet file format (.cab) was originally used
to compress software that was distributed on disks. This format
is now also used to reduce the file size and the associated
download time for Web components such as the mediaPlay ActiveX
control.
If you wish to place our mediaPlay CAB file on your own system
then download it here
.