Search code examples
c#iishtml5-audio

HTML5 audio element do not work in the internet information service server


I have created an audio stream starting from OBS to a RTMP followed by streaming from the RTMP Server via VLC to an HTTP stream. I have created the following HTML 5 Audio side:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <audio controls="controls" runat="server" autoplay="autoplay">
        <source src="http://innoszorn.ddnss.de:11001/stream.ogg" type="audio/ogg" />
    </audio>
</body>
</html>

Running the side in the Visual Studio 2017 envirnonment the player works. But after publishing the project to the IIS Server the player doesn't work anymore. Also with VLC you can connect to the stream.


Solution

  • Try to add the mime type in iis.IIS won’t serve .ogg files until you tell it about the type. add below code in your web.config file:

    <system.webServer>
      <staticContent>
        <mimeMap fileExtension=".ogg" mimeType="audio/ogg" />
      </staticContent>
    </system.webServer>
    

    you could also use iis manager to add the mime type:

    1)open iis manager.

    2)select your site.

    3)double click on the mime type feature from the middle pane.

    enter image description here

    4)click on the add from the action pane

    enter image description here

    5)add file extension and mime-type as shown below:

    enter image description here

    6)click ok and restart the site and browse it.

    Note: Make sure the file is available in the site folder. iusr and iis_iusrs have full permission to access the site folder.