...

View Full Version : Play a sound file using client's default media player



ASP
06-09-2003, 04:05 AM
Greetings...

I'd like to create a JavaScript function that will prompt the client to open/save a sound file. Opening the sound file would then open the client's default media player.

I've examined the code generated by the PlaySound Behavior in Dreamweaver MX. It is listed below.

==============================================
function MM_controlSound(x, _sndObj, sndFile) { //v3.0
var i, method = "", sndObj = eval(_sndObj);

if (sndObj != null) {
if (navigator.appName == 'Netscape') {
method = "play";
} else {
if (window.MM_WMP == null) {
window.MM_WMP = false;
for(i in sndObj) if (i == "ActiveMovie") {
window.MM_WMP = true; break;
}
}
}
if (window.MM_WMP) {
method = "play";
} else if (sndObj.FileName) {
method = "run";
}
}
if (method) {
eval(_sndObj+"."+method+"()");
} else {
window.location = sndFile;
}
}
//-->
</script>
</head>

<body onLoad="MM_controlSound('play','document.CS1055118834968','<some sound file')">
<EMBED NAME='CS1055118834968' SRC='<some sound file' LOOP=false
AUTOSTART=false MASTERSOUND HIDDEN=true WIDTH=0 HEIGHT=0></EMBED>
==============================================

How does the "onLoad() function know to pass 'document.CS1055118834968' as the second argument to the function "MM_controlSound". Furthermore, how I would be able to pass an argument that defines the client's default media player.

Secondly, my understanding is that the <embed> tag is no longer supported in NN7. More to the point, if the objective is to prompt the client to open the default media player for the sound file to play, why use an <embed> tag at all?

Your feedback is greatly appreciated.


Respectfully,

ASP

chrismiceli
06-09-2003, 05:46 AM
i think ns7 wants you to use the object tag, if you want the users to click it and they can download or open it, then just make the sound a link, and then they can click "open" or "save".
<a href="sound.wav">sound</a>
or the object is something like this
<object type="audio/x-wav" src="sound.wav">

the object stuff is just a guess, i never used the object tag, i think it is something like that though.

ASP
06-09-2003, 06:07 PM
Chris,

Thanks for your reply.

Unfortunately, while your anchor tag with hyperlink reference suggestion does work, it behaves in the same way as the code previously listed. That is, in IE6 a dialog box prompts the user to open/save the file, while in NN7 a new web page is opened, the basic controller is displayed and the sound file begins to play... argh!

I'll have to check your <object> tag suggestion. However, at least with respect to IE6 and NN7, I am striving for a DOM-based solution. I wonder if the <object> tag is defined in the Document Object Model, Level 1. It's time for more investigation.

Any further feedback is most appreciated.

Thanks again.


Respectfully,

ASP



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum