问题
There are a couple of web sites I maintain that use HTML audio/mp3 objects within a page. They use to work but then something broke. The pages rely on Windows Media Player if the client browser is IE.
A month or so ago, the object would appear as a WMP control. It should look like this
(source: calgarydj.ca)
But now what appears resembles a mail slot a tiny scrollbar attached.
Click on this link to view.
(source: calgarydj.ca)
I think this change may have occurred with the Jan 2009 Microsoft updates.
I have searched for answers but found only one other question regarding this. I have seen a few other sites with related problems. Here is another site that seems to be having the same problems - see this page for the audio example.
- Has anybody else experienced this problem? IE7 on windows XP (2 systems)
- Does this occur on Vista or just XP (or is it just my 2 systems)?
- Is there a fix?
Here is the html for a typical sound object
<div class="music">
<p>Pachelbel's Canon</p>
<object id="Cannon" type="audio/mpeg" data="./sound%20files/Pachebels%20Cannon.mp3" width="250" height="16">
<param name="autoplay" value="false" />
<param name="src" value="./sound files/Pachebels%20Cannon.mp3" />
<object id="Cannon" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="250" height="50">
<param name="autostart" value="false" />
<param name="url" value="./sound%20files/Pachebels Cannon.mp3" />
<param name="showcontrols" value="true" />
<param name="volume" value="100" />
</object>
</object>
</div><!-- end of control -->
This is a pretty cool site. But I have tried to add images to this post and the images never appear on the final post. What am I missing?
回答1:
So I ended up using IE conditional comments (ugh!) to remedy the problem. This is ugly but it works. It even validates as XHTML.
There are still 2 nested objects but now an IE conditional comment wrapper hides the first object so IE does not see it, only the second. Firefox, Safari and Chrome see the first object and use the Quicktime plugin (if installed) to render a control.
The other browsers ignore the IE conditional comments because they look like a regular open/closed comment block with a little gibberish in the middle.
NOTE: The ticks(`) surrounding the comment lines below do not belong there, but you do what is necessary to get things to work around here.
`<!--[if !IE]>-->`
<object id="Cannon" type="audio/mpeg" data="./sound%20files/Pachebels%20Cannon.mp3" width="250" height="16">
<param name="autoplay" value="false" />
<param name="src" value="./sound files/Pachebels%20Cannon.mp3" />
`<!--<![endif]>-->`
<object id="Cannon" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="250" height="60">
<param name="autostart" value="false" />
<param name="url" value="./sound%20files/Pachebels Cannon.mp3" />
<param name="showcontrols" value="true" />
<param name="volume" value="100" />
`<!--[if !IE]>--></object><!--<![endif]-->`
</object>
Not long ago IE7 used to ignore audio/mpeg type objects unless they had a legit CLSID tag for Windows Media Player (WMP). Since the second object (in my previous model), did have a CLSID, IE would render a WMP control and everything would be just ducky. The other browsers would simply recognize the first object and use the Quicktime plugin for a sound control.
On December 9, 2008, Microsoft released another Windows Media Player security update. Everything still worked like before (for me). This was followed with another update on Jan 13, 2009, intended, in part, to patch the December 9th WMP update. (see this article). That is when things stopped working (on IE).
Now IE7 (on XP) renders the no-class objects as something that looks like a mail-slot with a scrollbar. They are about as useful as a mail slot on an LCD screen. And the IE browser, satisfied it has done it's job, ignores the second object with the correct CLSID nested within.
So IE's own conditional comments got me out of a pickle here but it was Microsoft that threw a wrench into its own browser! Why Microsoft? Why?
回答2:
I strongly suggest using Adobe Flash to play music on a website. It is almost bulletproof in comparison to using external players like Windows Media Player and you will also have full control of the look of your player.
来源:https://stackoverflow.com/questions/574565/jan-2009-microsoft-update-breaks-mp3-sound-objects-in-ie7