Stopping/starting WMA

A

Andrew Poulos

I'm using Windows Media Audio, via a WAX file, and I have some custom
controls to start and stop the audio. While it works in IE, FF gives an
error. The HTML looks like this:

<object id='obj' type='audio/x-ms-wax'
style='position:absolute; left:0px; top:0px;'
classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'
codeBase='http://activex... blah
width='100' height='100'>
<param name='FileName' value='wma_sample.wax'>
<param name='AutoStart' value='0'>

<embed id='objff' type='audio/x-ms-wax'
src='wma_sample.wax' autostart='0' width='100' height='100'></embed>
</object>

and the relevant FF JavaScript look like this:

if (typeof document.getElementById('objff').Play != "undefined") {
document.getElementById('objff').Play();
} else {
alert("An error occurred and the audio could not be played.");
}


If I change the type and the sample to an MP3 file then the custom
controls work in FF. Is there a way to get FF to control WMA?

Andrew Poulos
 
C

cwdjrxyz

Andrew said:
I'm using Windows Media Audio, via a WAX file, and I have some custom
controls to start and stop the audio. While it works in IE, FF gives an
error. The HTML looks like this:

<object id='obj' type='audio/x-ms-wax'
style='position:absolute; left:0px; top:0px;'
classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'
codeBase='http://activex... blah
width='100' height='100'>
<param name='FileName' value='wma_sample.wax'>
<param name='AutoStart' value='0'>

<embed id='objff' type='audio/x-ms-wax'
src='wma_sample.wax' autostart='0' width='100' height='100'></embed>
</object>

The above code usually works, but you will find many validation errors
if you check it at the W3C validator. Briefly, this code uses an
ActiveX object for browsers that support it(mainly IE). The ActiveX
path is valid code for browsers that support it. For the many browsers
that do not support ActiveX for the WMP, the embed path is
automatically taken. This usually works, but embed is a hangover from
the browser war era and has never been part of official W3C html. Hence
the validation errors you will get. However this can all be avoided.

See http://www.cwdjr.info/souearly/mixedtestRoot.php and view the
source code. This code will work for the WMP using a .wax
redirector/playlist file, and the wax file can include several songs in
wma, mpg, wav, midi etc formats that will play in sequence. The WMP is
a huge program, about 3 to 4 times the size of many lean browsers such
as Firefox. It has many controls built in, so why reinvent the wheel?
You can have anything from a simple on/off button with auto start or
not, up to much more elaborate controls such as on my demo page.
Controlling the WMP with custom written script can be very tricky and
has varied some with WMP updates. There used to be quite a bit about
this subject on the vast Microsoft developers sites. However you will
find that many of the controls they use are aimed at IE only. Some use
vbscript that most browsers do not support. Some use Microsoft's
Jscript. I used to write scripts to control the WMP, but I now would do
it only as a last resort. For example, one of the Microsoft scripts
used to detect the WMP version failed after an upgrade, and I had to go
in and revise the Jscript and a vbscript - and all of this just to play
correctly on IE.

In addition to the code I show on my page, it is also possible to use
Microsoft conditional html comments to use an ActiveX path for IE and
an object path for everything else. This might be of limited use if one
wanted to use a parameter on IE that is only supported by an ActiveX
control and do something else for other browsers. I also have code for
this, but it is unlikely to be needed for your application.
 
A

Andrew Poulos

cwdjrxyz said:
The above code usually works, but you will find many validation errors
if you check it at the W3C validator. Briefly, this code uses an
ActiveX object for browsers that support it(mainly IE). The ActiveX
path is valid code for browsers that support it. For the many browsers
that do not support ActiveX for the WMP, the embed path is
automatically taken. This usually works, but embed is a hangover from
the browser war era and has never been part of official W3C html. Hence
the validation errors you will get. However this can all be avoided.

See http://www.cwdjr.info/souearly/mixedtestRoot.php and view the
source code. This code will work for the WMP using a .wax
[snip]

Thanks for the code but my problem is not playing WMA/WAX files in
Firefox it's starting and stopping them using JavaScript.

Andrew Poulos
 
C

cwdjrxyz

Andrew said:
Thanks for the code but my problem is not playing WMA/WAX files in
Firefox it's starting and stopping them using JavaScript.

Sorry, but I do not exactly know what you mean. It would help if you
gave a working page so that people could see exactly what is going on
and exactly what you need to do. The built in controls in the WMP
object as I illustrated will of course allow you to start or stop the
WMP at will by clicking the player button. This works for IE6 and
recent versions of Firefox, Opera, Netscape, and Mozilla browsers. Your
answer leads me to think that you may wish to start or stop
automatically upon some event happening rather than by clicking a
start/stop button, but without a working code, I can not be sure.
 
A

Andrew Poulos

cwdjrxyz said:
Sorry, but I do not exactly know what you mean. It would help if you
gave a working page so that people could see exactly what is going on
and exactly what you need to do. The built in controls in the WMP
object as I illustrated will of course allow you to start or stop the
WMP at will by clicking the player button. This works for IE6 and
recent versions of Firefox, Opera, Netscape, and Mozilla browsers. Your
answer leads me to think that you may wish to start or stop
automatically upon some event happening rather than by clicking a
start/stop button, but without a working code, I cannot be sure.

There's nothing wrong, as such, with your code. It's just that I don't
want to have the standard WMP controls visible. There's a minimal custom
interface that's to use JavaScript to control the playback.

Andrew Poulos
 
C

cwdjrxyz

Andrew said:
There's nothing wrong, as such, with your code. It's just that I don't
want to have the standard WMP controls visible. There's a minimal custom
interface that's to use JavaScript to control the playback.

I am still not certain I understand exactly what you are wishing to do
without a working example. Since you mentioned a minimal interface, I
just wanted to show you an example of the minimal standard WMP built in
control that is reduced to a start/stop button. See
http://www.cwdjr.info/dhtml/7veilsDance.html . Scroll to the bottom of
the source code to see the player object code. As you will see from all
of the dhtml on the page, I am not adverse to using script in general.
It is just that I avoid it for the WMP when possible for reasons
mentioned in my first post. There have been many posts here and in the
alt.html group over the years concerning problems on some browsers
using script to control the WMP. If you are content with controlling
only on IE browsers, there often is a solution. For other browsers,
there often are complications, as you found in your case. Hopefully
someone else will come along with more information for you. If you
provide a working page example using your code that works on IE and the
code that does not work on Firefox, you are much more likely to get
more responses
 
A

Andrew Poulos

cwdjrxyz said:
I am still not certain I understand exactly what you are wishing to do
without a working example. Since you mentioned a minimal interface, I
just wanted to show you an example of the minimal standard WMP built in
control that is reduced to a start/stop button. See
http://www.cwdjr.info/dhtml/7veilsDance.html .

I'm not sure I can explain it much simpler.

- I do *not* want the WMP interface visible at all.
- I want to be able to call a JavaScript function that plays the WMA/WAX.
- I want to be able to call another JavaScript function that stops the
WMA/WAX.

Andrew Poulos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top