IE bug Invalid Source HTML5 audio - workaround

一世执手 提交于 2019-12-13 12:02:08

问题


I (and about a million others) have found a bug in IE11 (not sure if other versions have the same bug) where, if you create an HTML5 audio tag, the browser reports "Invalid Source" no matter what. I've tried every combination I can think of with no luck. So far: Changing the HTML end tags from self-closing to explicit Changing the file name to eliminate any odd characters Changing the audio sub format to every possible setting Adding an explicit URI ("http:// ...") Disabling all plugins (there were on the stock plugins) Trying every possible audio format Defining the MIME type Changing the audio tag's parameters. Changed the IIS settings to include the MIME types.

Checking Microsoft's "Connect" website - (they make the claim that it is not reproducible, but hundreds of thousands of Google results suggest otherwise).

Is this no possible at all? ALL other latest & greatest browsers I tried work (FireFox, Opera, Safari, Chrome) I'm at wit's end - no solutions work.

Here's the code:

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="AudioPopupPlayer.aspx.vb" Inherits="AudioPopupPlayer" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
        <div style="padding-top: 30px; margin: auto; width: 300px;">
        <asp:Literal ID="litVoiceOver" runat="server"></asp:Literal></div>
</body>
</html>

Code behind:

Partial Class AudioPopupPlayer
Inherits System.Web.UI.Page

Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    Dim VoiceOverFileName As String = Request.QueryString("vo")
    If VoiceOverFileName.Length > 0 Then
        Dim root As String = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + ResolveUrl("~/")
        Dim audiosource As String = "<audio id=""VoiceOver"" autoplay=""autoplay"" preload=""preload"" controls=""controls""><source src=""" & root & "audio/" & VoiceOverFileName & ".ogg"" type=""audio/ogg"" ></source><source src=""" & root & "audio/" & VoiceOverFileName & ".mp3"" type=""audio/mpeg"" ></source><source src=""" & root & "audio/" & VoiceOverFileName & ".wav"" type=""audio/wav"" ></source></audio>"
        Me.litVoiceOver.Text = audiosource
    End If
End Sub

 End Class

And, finally, a screenshot (in IE11) showing that the HTML is rendered perfectly, yet I still get the dreaded "Invalid Source" message (NOTE: copying and pasting the link causes the audio file to play - go figure).


回答1:


I had the same issue trying to use the simple HTML5 code. The url and file name were correct as well. This is what worked for me:

<audio src="song.mp3" controls autoplay></audio>

You can remove the controls if you don't need them, it's still going to work. I hope this helps!




回答2:


I tried a couple of new file formats. Internet Explorer 11 only supports the M4A audio format (WAV, OGG & MP3 are not supported). Microsoft really needs to put the correct information on their website about what their browser supports (they claim MP3 is supported, but clearly, it is not). Madness, I tell you!




回答3:


We have experienced the same issue in a corporate environment with fresh installs of IE11 and Windows 7.

We have resolved the issue by installing the K-Lite media pack and have an alternate MP3 codec installed. Then it worked.




回答4:


A comment from here:

Posted by Jonathan Laughery on 23.5.2014 at 22:19 This is because IE's HTML5 audio tag doesn't support WAV PCM format. This is especially weird because IE does support WAV PCM in the deprecated bgsound tag, WAV PCM has been the native Microsoft Windows audio format forever, and Microsoft's is the only major browser that doesn't support it. WAVs are still popular in sound archives and used on corporate networks, but playing WAVs in IE requires the bgsound tag (IE-specific, deprecated, and poor control), transcoding on the server, or using a flash player (like jPlayer's fallback) which is what the HTML5 audio tag was designed to avoid. Please add this format.

Here's the documentation about bgsound . If you going to use bgsound this might be helpful




回答5:


Check the browser's response headers for the audio file response. I ran into this issue due to a server not being configured to send the audio file as an audio/mpeg. Someone had mp3s set to application/octet-stream in IE. Once I fixed this, everything worked fine.



来源:https://stackoverflow.com/questions/24213302/ie-bug-invalid-source-html5-audio-workaround

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!