By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,441 Members | 1,766 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,441 IT Pros & Developers. It's quick & easy.

FireFox and Windows Media Player

P: n/a
Hi all,

I'm trying to use WMP in FireFox and I have the following tag to embed
the player into the html page.

<EMBED TYPE="application/x-mplayer2"

PLUGINSPAGE="http://microsoft.com/windows/mediaplayer/en/download/"
ID="wmp"
Name="wmp"
DISPLAYSIZE="4"
AUTOSIZE="-1"
BGCOLOR="darkblue"
SHOWCONTROLS="-1"
SHOWTRACKER="-1"
SHOWDISPLAY="0"
SHOWSTATUSBAR="-1"
VIDEOBORDER3D="-1"
WIDTH=320
HEIGHT=313
SRC=""
AUTOSTART="-1"
DESIGNTIMESP="5311">
</EMBED>

Problem is that I can't access the controls through JavaScript. I have
to change the SRC property and play a new file according to user input.

var w = document.getElementById('wmp');

// This doesn't work... JavaScript error: "Play is not function"
wmp.Play();

// this also doesn't work... "controls is undefined"
wmp.controls.Play();

Anyone knows how to control WMP via JavaScript? I'm googling all over,
but I can't find a piece of code that shows me how to do it...

Thanks in advance!

Jun 2 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a

JulioHM wrote:
Hi all,

I'm trying to use WMP in FireFox and I have the following tag to embed
the player into the html page.

<EMBED TYPE="application/x-mplayer2"

PLUGINSPAGE="http://microsoft.com/windows/mediaplayer/en/download/"
ID="wmp"
Name="wmp"
DISPLAYSIZE="4"
AUTOSIZE="-1"
BGCOLOR="darkblue"
SHOWCONTROLS="-1"
SHOWTRACKER="-1"
SHOWDISPLAY="0"
SHOWSTATUSBAR="-1"
VIDEOBORDER3D="-1"
WIDTH=320
HEIGHT=313
SRC=""
AUTOSTART="-1"
DESIGNTIMESP="5311">
</EMBED>

Problem is that I can't access the controls through JavaScript. I have
to change the SRC property and play a new file according to user input.

var w = document.getElementById('wmp');

// This doesn't work... JavaScript error: "Play is not function"
wmp.Play();

// this also doesn't work... "controls is undefined"
wmp.controls.Play();

Anyone knows how to control WMP via JavaScript? I'm googling all over,
but I can't find a piece of code that shows me how to do it...


I can not be certain exactly what you wish to do without an example on
a web page. The WMP can be used to play audio or video. From the width
and height you use, I am guessing you are allowing room for a video. If
at all possible, avoid trying to control the WMP with script. First,
embed has never been an official tag, and object is the modern method.
Of course many sites still use tag soup with an ActiveX object for IE
and an embed path within the AE object for most other browsers that do
not support AE. You will find the W3C validator does not like this soup
or use of a simple embed tag.

The WMP has many controls built in that can be specified in a correct
object tag, so it usually is not necessary to make your own controls
using script or whatever.

Go to a page of mine at
http://www.cwdjr.info/broadbandMedia.../cancanWMV.php and look
at the object code that inserts the WMP with controls. This video uses
a very high variable bit rate wmv video file, so it may not stream on
dialup without an extremely long buffering time. The average bit rate
is about 1919 kbps. You will notice that the object for the video calls
for a .wvx file which is a redirector file; the actual video file is a
..wmv file. The .wvx file has a simple XML structure that points to the
..wmv file, and the one used in this example is:

<ASX VERSION="3.0">
<ENTRY>
<REF HREF="http://www.cwdjr.info/movie/CanCanvbr.wmv" />
</ENTRY>
</ASX>

On broadband, that will allow about 2.5 Mbps, buffering of the above
sample is quite fast, and you can click on the video shortly when
buffering is completed. For good dialup, you would need a video
recorded at not more than about 30 kbps, and the image would need to be
kept quite small. Even so, streaming video leaves much to be desired on
dialup. My example works on most recent popular browsers with the WMP
installed including IE6, Opera, and the Mozilla family(Firefox,
Mozilla, Netscape).

If you absolutely must use script to control the WMP, there used to be
some information somewhere on the Microsoft developers sites. However,
if I remember correctly, some of the uses of script discussed there
used Microsoft Jscript, some examples were designed to work on ActiveX
objects that often are not supported by non-IE browsers, and some
scripts to detect the WMP and version used vb script that does not work
on many non-IE browsers. One likely could spend days at Microsoft
developer sites finding scripts and testing, and often changing them
for non-IE browsers.

Jun 3 '06 #2

P: n/a
Thanks for the reply, and sorry for the lack of more info.

Well, I'm trying to use WMP to play sound files. The size of the
embeded object would be reduced to show only the player controls. But
that's not really the important thing on my problem.

I have the need to use JavaScritp to control the player (that's the
issue), because the contents of the player (the file which must be
played) vary according to where the use clicks on the webpage.

I'm starting to guess there is no way around that... since it's a
micro$oft product... maybe the only way to control it via scripting is
inside IE.

But thanks anyway. I'll keep waiting for any good soul who knows the
answer :)

Thanks!

cwdjrxyz escreveu:
JulioHM wrote:
Hi all,

I'm trying to use WMP in FireFox and I have the following tag to embed
the player into the html page.

<EMBED TYPE="application/x-mplayer2"

PLUGINSPAGE="http://microsoft.com/windows/mediaplayer/en/download/"
ID="wmp"
Name="wmp"
DISPLAYSIZE="4"
AUTOSIZE="-1"
BGCOLOR="darkblue"
SHOWCONTROLS="-1"
SHOWTRACKER="-1"
SHOWDISPLAY="0"
SHOWSTATUSBAR="-1"
VIDEOBORDER3D="-1"
WIDTH=320
HEIGHT=313
SRC=""
AUTOSTART="-1"
DESIGNTIMESP="5311">
</EMBED>

Problem is that I can't access the controls through JavaScript. I have
to change the SRC property and play a new file according to user input.

var w = document.getElementById('wmp');

// This doesn't work... JavaScript error: "Play is not function"
wmp.Play();

// this also doesn't work... "controls is undefined"
wmp.controls.Play();

Anyone knows how to control WMP via JavaScript? I'm googling all over,
but I can't find a piece of code that shows me how to do it...


I can not be certain exactly what you wish to do without an example on
a web page. The WMP can be used to play audio or video. From the width
and height you use, I am guessing you are allowing room for a video. If
at all possible, avoid trying to control the WMP with script. First,
embed has never been an official tag, and object is the modern method.
Of course many sites still use tag soup with an ActiveX object for IE
and an embed path within the AE object for most other browsers that do
not support AE. You will find the W3C validator does not like this soup
or use of a simple embed tag.

The WMP has many controls built in that can be specified in a correct
object tag, so it usually is not necessary to make your own controls
using script or whatever.

Go to a page of mine at
http://www.cwdjr.info/broadbandMedia.../cancanWMV.php and look
at the object code that inserts the WMP with controls. This video uses
a very high variable bit rate wmv video file, so it may not stream on
dialup without an extremely long buffering time. The average bit rate
is about 1919 kbps. You will notice that the object for the video calls
for a .wvx file which is a redirector file; the actual video file is a
.wmv file. The .wvx file has a simple XML structure that points to the
.wmv file, and the one used in this example is:

<ASX VERSION="3.0">
<ENTRY>
<REF HREF="http://www.cwdjr.info/movie/CanCanvbr.wmv" />
</ENTRY>
</ASX>

On broadband, that will allow about 2.5 Mbps, buffering of the above
sample is quite fast, and you can click on the video shortly when
buffering is completed. For good dialup, you would need a video
recorded at not more than about 30 kbps, and the image would need to be
kept quite small. Even so, streaming video leaves much to be desired on
dialup. My example works on most recent popular browsers with the WMP
installed including IE6, Opera, and the Mozilla family(Firefox,
Mozilla, Netscape).

If you absolutely must use script to control the WMP, there used to be
some information somewhere on the Microsoft developers sites. However,
if I remember correctly, some of the uses of script discussed there
used Microsoft Jscript, some examples were designed to work on ActiveX
objects that often are not supported by non-IE browsers, and some
scripts to detect the WMP and version used vb script that does not work
on many non-IE browsers. One likely could spend days at Microsoft
developer sites finding scripts and testing, and often changing them
for non-IE browsers.


Jun 20 '06 #3

P: n/a

JulioHM wrote:
Thanks for the reply, and sorry for the lack of more info.

Well, I'm trying to use WMP to play sound files. The size of the
embeded object would be reduced to show only the player controls. But
that's not really the important thing on my problem.

I have the need to use JavaScritp to control the player (that's the
issue), because the contents of the player (the file which must be
played) vary according to where the use clicks on the webpage.

I'm starting to guess there is no way around that... since it's a
micro$oft product... maybe the only way to control it via scripting is
inside IE.


Since you need several audio links, you can write a mini player for
each link and place it on the desired part of the page using absolute
positioning. See http://www.cwdjr.info/media/playersRoot.php and select
the WMP(SCRIPT) link at the top of the page for an example. I used php
on the server to write the long division containing all of the players
using the php equivalent of document.write for a loop that positions
all of the players down the left side of the page by a fixed increment
for each player. This saved me a lot of work. However you could just as
well write any set of positions you desire by hand. This could place
the tiny mini players, each with only a start/stop button all over the
page as desired. This may not be exactly what you seem to want, because
the buttons will show. However it may give you some ideas. Although my
example page is long, about all you need to consider in it is the
division that writes all of the players.

Jun 20 '06 #4

P: n/a
Thanks.. but still.. I need to script code to start the player with an
user action (eg: onClick). I haven't been able to find the JavaScript
code to do that.

wmp.Play() just won't do it.

cwdjrxyz wrote:
JulioHM wrote:
Thanks for the reply, and sorry for the lack of more info.

Well, I'm trying to use WMP to play sound files. The size of the
embeded object would be reduced to show only the player controls. But
that's not really the important thing on my problem.

I have the need to use JavaScritp to control the player (that's the
issue), because the contents of the player (the file which must be
played) vary according to where the use clicks on the webpage.

I'm starting to guess there is no way around that... since it's a
micro$oft product... maybe the only way to control it via scripting is
inside IE.


Since you need several audio links, you can write a mini player for
each link and place it on the desired part of the page using absolute
positioning. See http://www.cwdjr.info/media/playersRoot.php and select
the WMP(SCRIPT) link at the top of the page for an example. I used php
on the server to write the long division containing all of the players
using the php equivalent of document.write for a loop that positions
all of the players down the left side of the page by a fixed increment
for each player. This saved me a lot of work. However you could just as
well write any set of positions you desire by hand. This could place
the tiny mini players, each with only a start/stop button all over the
page as desired. This may not be exactly what you seem to want, because
the buttons will show. However it may give you some ideas. Although my
example page is long, about all you need to consider in it is the
division that writes all of the players.


Jun 20 '06 #5

P: n/a

JulioHM wrote:
Thanks.. but still.. I need to script code to start the player with an
user action (eg: onClick). I haven't been able to find the JavaScript
code to do that.


I must be missing something here. If you place the multiple mini
players at points on the page where needed as I suggested, then a click
on their buttons will start or stop the player for that area. You gave
a desired user action example as on Click and that is what the player
buttons do!. Perhaps you had an on mouseover in mind. For example, when
you move the cursor to anywhere over a defined area of the page, a
sound for that area starts playing. This can be fairly easily scripted
for IE where you use an ActiveX object for the player. Unfortunately
this method fails for most other browsers that do not support an
ActiveX object for the WMP. Many of the WMP script controls that you
find at Microsoft work only for an ActiveX WMP object. I could post a
link to an old mouseover effect that plays sound on IE only, but I
hesitate to do anything else unless I understand better exactly what
you are after. Not having a page you wrote as a starting point makes
this rather difficult.

Jun 21 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.