Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-09-2003, 04:05 AM   PM User | #1
ASP
New Coder

 
Join Date: Jun 2003
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
ASP is an unknown quantity at this point
Play a sound file using client's default media player

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
ASP is offline   Reply With Quote
Old 06-09-2003, 05:46 AM   PM User | #2
chrismiceli
Regular Coder

 
Join Date: Sep 2002
Location: Louisiana
Posts: 576
Thanks: 0
Thanked 0 Times in 0 Posts
chrismiceli is an unknown quantity at this point
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.
__________________
DevEdge - MSDN - DevGuru
chrismiceli is offline   Reply With Quote
Old 06-09-2003, 06:07 PM   PM User | #3
ASP
New Coder

 
Join Date: Jun 2003
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
ASP is an unknown quantity at this point
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
ASP is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:24 PM.


Advertisement
Log in to turn off these ads.