Join the AMA (Ask Me Anything) with the Firefox leadership team to celebrate Firefox 20th anniversary and discuss Firefox’s future on Mozilla Connect. Mark your calendar on Thursday, November 14, 18:00 - 20:00 UTC!

Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Web site wont play asf sound

more options

While visiting web site, sognoromance.com/ladyinred.htm, pages do not play sound in ASF format or WMA. They do with IE. I have installed plug in, tested and desabled them all to no avail.

Is there a way to be able to hear sound?

Thank you

While visiting web site, sognoromance.com/ladyinred.htm, pages do not play sound in ASF format or WMA. They do with IE. I have installed plug in, tested and desabled them all to no avail. Is there a way to be able to hear sound? Thank you

Isisombulu esikhethiweyo

It has been a while since I tried to create a Windows Media player for both IE and Firefox, so I don't know the latest thinking. You could try this as a complete replacement for your existing video script:


<script type="text/javascript"> function makePlayer(sURL){ var o=document.createElement("object"); o.setAttribute("type","application/x-mplayer2"); o.setAttribute("data",sURL); var p=document.createElement("param"); p.setAttribute("name","src"); p.setAttribute("value",sURL); o.appendChild(p) document.body.appendChild(o); } makePlayer("http://path/to/song.asf"); </script>

You can find more web development help on the mozillaZine Web Development board. Separate forum, separate registration.

{Case corrected on function's input parameter per cor-el's very observant post below.}

Funda le mpendulo kwimeko leyo 👍 1

All Replies (18)

more options

The script that creates the player uses a reference to the Windows Registry (classid="CLSID..."). Firefox ignores any object like that.

Do you think the site would be willing to fix its pages? If not, you can inject your own player into the page using a little script.

One quick and dirty way to do this is a bookmarklet, which is a little script you save as a bookmark. The problem is that different pages on the site have different scripts, so it's hard to create a universal yet simple solution.

Here's one which worked on 3 pages but failed on one of the others. Visit the above page, delete the contents of the address bar, paste this entire script there, and press Enter. The song should start to play.


javascript:var o=document.createElement("object"); o.setAttribute("type","application/x-ms-wmp"); if(window.songURL!=undefined) o.setAttribute("data",songURL); else if(window.pathName!=undefined) o.setAttribute("data",pathName); document.body.appendChild(o); void 0;

---

For quick access, you can add a button to your Bookmarks Toolbar with that script.

First, copy the entire code to the clipboard.

Next, if you are not displaying the Bookmarks Toolbar, use View > Toolbars > Bookmarks Toolbar to display it.

Right-click on the Bookmarks Toolbar (or Mac equivalent of right-click!) and choose New Bookmark.

Paste the code into the Location box (the second box).

Then type a useful name in the Name box (e.g., SongPlayer) and click Add.

Now, when you want to add the feature to a page, click the button to run the script.

---

Manual clicking is a hassle, but unless this site is very important to you, it may not pay to invest further time automating the solution.

Ilungisiwe ngu jscher2000 - Support Volunteer

more options

Thank you for your reply.

Yes, I can make changes to web pages. Where on web page would I insert this code? Thank you.

If I enter that code into my HTML page, would both browsers be able to play the sound? The IE and Firefox?

If so, I'd like to than add that code to all my pages. By entering this code I can than remove the CLSID code, right? Or, is this code in addition to the CLSID code?

I did try that code and it played fine. Wonderful.

Ilungisiwe ngu sogno

more options

Isisombululo esiKhethiweyo

It has been a while since I tried to create a Windows Media player for both IE and Firefox, so I don't know the latest thinking. You could try this as a complete replacement for your existing video script:


<script type="text/javascript"> function makePlayer(sURL){ var o=document.createElement("object"); o.setAttribute("type","application/x-mplayer2"); o.setAttribute("data",sURL); var p=document.createElement("param"); p.setAttribute("name","src"); p.setAttribute("value",sURL); o.appendChild(p) document.body.appendChild(o); } makePlayer("http://path/to/song.asf"); </script>

You can find more web development help on the mozillaZine Web Development board. Separate forum, separate registration.

{Case corrected on function's input parameter per cor-el's very observant post below.}

Ilungisiwe ngu jscher2000 - Support Volunteer

more options

Thank you very much for your assistance.

The code you posted I will use to replace the CLSID code for WMP.

In your code, does it tell how many times to play audio file (ASF), or is it once only be default?

I will visit that other place you mentioned.

Thanks again for your kindness.

Regards,

more options

In your code, does it tell how many times to play audio file (ASF), or is it once only be default?

You would need to add another <param> to the object to specify that.

more options

Thank you.

I will try that and do some more playing with your code.

more options

A small nit: function makePlayer(sUrl) -> function makePlayer(sURL) :wink:

more options

Could you please give an example of how to write that <PARAM>?

I don't see one in your code. Much appreciated.

more options

Cor-el,

I don't understand what you mean. Could you explain, please?

more options

Could you please give an example of how to write that <PARAM>?

Insert another set of these four lines after the first group for each additional PARAM:


p=document.createElement("param"); p.setAttribute("name","playCount"); p.setAttribute("value","1"); o.appendChild(p)

---

cor-el was pointing out that I had mismatched the case between sUrl and sURL. So I fixed that in the earlier post.

Ilungisiwe ngu jscher2000 - Support Volunteer

more options

Thank you again for your time and effort.

The last four lines, they are to be inserted before the </SCRIPT> tag, right?

more options

You need to place those lines in the body of the function makePlayer before the appendChild(o) call that moves the object in the DOM tree.

function makePlayer(sURL){
 var o=document.createElement("object");
 o.setAttribute("type","application/x-mplayer2"); 
 o.setAttribute("data",sURL);

 var p=document.createElement("param");
 p.setAttribute("name","src");
 p.setAttribute("value",sURL);
 o.appendChild(p);

 p=document.createElement("param");
 p.setAttribute("name","playCount");
 p.setAttribute("value","1");
 o.appendChild(p);

 document.body.appendChild(o);
}

Ilungisiwe ngu cor-el

more options

Cor-el,

Thanks for the code... but now I am confused.

Is this the hole code or just a part to add to what jscher2000 has created?

The whole code, is it to be placed in the HTML part of source or in the script part (java script) before the </BODY></HTML> tags?

That's where I had my CLSID code.

Thank you for explaining.

more options

This is only the makePlayer part of the code that jscher2000 posted above.
I added some blank lines to make it easier to read the code.

The full code need to include the script tags and the call to make that player (substitute the correct URL of the ASF file).
You can place the code in the HEAD section or possibly at the end of the BODY before </body> as that is where the player code is added via appendChild().


<script type="text/javascript">
function makePlayer(sURL){
 var o=document.createElement("object");
 o.setAttribute("type","application/x-mplayer2"); 
 o.setAttribute("data",sURL);

 var p=document.createElement("param");
 p.setAttribute("name","src");
 p.setAttribute("value",sURL);
 o.appendChild(p);

 p=document.createElement("param");
 p.setAttribute("name","playCount");
 p.setAttribute("value","1");
 o.appendChild(p);

 document.body.appendChild(o);
}

makePlayer("http://path/to/song.asf");
</script>
more options

Before the </BODY> tag I had this code to call out WMP.

Thye HTML code is above the WMP. All of my pages are done in similar style.

<!--Enter the full URL for your streaming sound in the Script below -->

<SCRIPT language=JavaScript>
// Insert the complete URL to stream the wma from
pathName="http://www.sognoromance.com/Music/ladyred.asf"
 
// Create the Media Player with nothing visible and Play the stream
player="<OBJECT ID='Player' CLASSID='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6' style='position:absolute;top:-1800'>"
player=player+"<PARAM name='uiMode' value='invisible'>"
player=player+"<PARAM name='autoStart' value='True'>"
player=player+"<PARAM name='playCount' value=1>"
player=player+"<PARAM name='volume' value=100>"
player=player+"<PARAM name='URL' value='"+pathName+"'>"
player=player+"</OBJECT>"
document.writeln (player);
</SCRIPT>

</body>

</html>


So, I can take the code you just provided and replace the one I had before, right? With this code inserted, I understand that Firefox can play it, right?

Those that visit the site with IE, will theyn also be able to hear the sound?

I'm sorry to be asking so many questions. I need to know so that I can adjust every page as well as for those I make in the future.

Much obliged for your help.

Ilungisiwe ngu cor-el

more options

Yes.
If you want to keep the other parameters then add a PARAM section for each of them


 p=document.createElement("PARAM");
 p.setAttribute("name","xxx");
 p.setAttribute("value","###");
 o.appendChild(p);
more options

Thank you.

I presume that "xxx and ###" are the items for me to fill out, if needed to be added.

Why is it that Firefox cannot read the MS code for player?

more options

Why is it that Firefox cannot read the MS code for player?

As noted above, the original code uses a reference to the Windows Registry (classid="CLSID..."). The reference is to a COM object, also known as an ActiveX control. Firefox does not run ActiveX controls, so these objects are ignored.