You need to embed your player into the page using the <object> tag for IE and the <embed> tag for NS. You can encapsulate the <embed> in the <object> so that IE only sees the <object> and NS only sees the <embed>.
eg:
[tt]
<OBJECT
ID="Video"
WIDTH="320"
HEIGHT="240"
CODEBASE="http://activex.microsoft.com/activex/controls/ mplayer/en/nsmp2inf.cab#Version=5,1,52,0701"
CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
STANDBY="Loading Windows Media Player components..."
TYPE="application/x-oleobject">
<EMBED
TYPE="application/x-mplayer2"
PLUGINSPAGE="http://www.microsoft.com/Windows/Downloads/ Contents/Products/MediaPlayer/"
SRC=""
NAME="Video"
WIDTH="320"
HEIGHT="240"
ShowControls="0"
ShowStatusBar="0"
ShowDisplay="0"
AnimationAtStart="1"
TransparentAtStart="0"
AutoStart="1"
AllowChangeDisplaySize="1">
</EMBED>
</OBJECT>
[/tt]
[sub]Ignore the spaces after the slashes in the URLs... they are only there so it would line break and not scroll all the way across the page.
[/sub]
Now, in order to access the plugin from JavaScript, it can be referenced as document.Video or, what I like to do is to name a simple variable:
[tt]
var Player = document.Video;
[/tt]
To assign a file, you should do one of two things. One, you could set the FileName and SRC attributes in the tags. Two, you could set it via JavaScript:
[tt]
if (IE) {Player.FileName = your_file;}
else {Player.SetFileName(your_file);}
[/tt]
This way you can set it dynamically by choosing amongst several files, for instance. your_file can be any media type that WMP can play (mp3, wav, asf, wmf, etc).
In order to play the file, you should use:
[tt]
Player.Play();
[/tt]
There are many other functions you can use, such as stop, fast forward, pause, rewind, etc. There are also other attributes you can access such as the position, packets received, reception quality, etc. Download the WMP SDK from http://www.microsoft.com for more info on that.
On Netscape, before using the media player functions, you have to initialize the plugin. In your body tag, call a function onload (ie. onLoad="start()"). In that function, you should register your event observers. Below is an example of my start() function:
[tt]
function start()
{
if (!document.all) {document.all = document.layers};
Player = document.Video;
if (!IE) {RegisterEventObservers();}
}
function RegisterEventObservers()
{
document.appObs.setByProxyDSScriptCommandObserver(Player, true);
}
function OnDSScriptCommandEvt(command, param)
{
// default command code goes here...
// leave blank to just use the javascript functions
}
[/tt]
And somewhere after the <embed> tag in the body of your page, you need to define your applet:
[tt]
<script language="JavaScript">
<!-- // Load Windows Media Proxy Applet For Non-IE Browsers
if (!IE)
{
navigator.plugins.refresh();
document.write("\x3C" + "applet MYSCRIPT Code=NPDS.npDSEvtObsProxy.class");
document.writeln(" WIDTH=5 HEIGHT=5 NAME=appObs\x3E \x3C/applet\x3E");
}
//-->
</script>
[/tt]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.