Streaming Audio Files in ASP.NET

I was having a requirement to Stream Audio files in one of my on-going ASP.NET application; While I googled, I found that to Stream Audio files in a webpage, we need to use <object> tag.
The <object> element can support many different media types, like:

  • Pictures
  • Sounds
  • Videos
  • Other Objects

We just need to add the Windows Media Player reference using <object> tag with class ID. Windows Media Player comes in many different versions. The class IDs are different for different versions, with a list of parameters you can set (most of them are boolean and self explanatory).

For Windows Media Player 6.4; which I am using, classID should be clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95. The class ID for Windows Media Player 7 and later is: clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6. Many places on the internet it states that the class ID should be: clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95. This class ID is the old one, but it will work, because of backward compability. However, if you use the old class ID you will not be able to use the new features added to the component.

Below is Sample Code for adding <object> tag in your HTML design code which is having reference to Windows Media Player 6.4 with classID as clsid: 22D6F312-B0F6-11D0-94AB-0080C74C7E95.

        <div>
            <object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" id="MediaPlayer1">
                <param name="AudioStream" value="true">
                <param name="AutoSize" value="true">
                <param name="AutoStart" value="false">
                <param name="ClickToPlay" value="true">
                <param name="Enabled" value="true">
                <param name="Filename" value="BilloRani_Goal.mp3"> <%--The URL of the file name you want to play--%>
                <param name="AnimationAtStart" value="true">
                <param name="ShowDisplay" value="true">
                <param name="ShowAudioControls" value="true">
                <param name="ShowDisplay" value="true">
                <param name="ShowStatusBar" value="true">
                <param name="ShowGotoBar" value="true">               
            </object>           
        </div>

Here are the list of parameters you can use with Windows Media Player 6.4 reference, they are almost self explanatory: Windows Media Player Reference in ASP.NET

Comments

# Streaming Audio Files in ASP.NET &laquo; KaushaL.NET

Saturday, September 06, 2008 1:45 AM by Streaming Audio Files in ASP.NET « KaushaL.NET

Pingback from  Streaming Audio Files in ASP.NET « KaushaL.NET

# re: Streaming Audio Files in ASP.NET

Wednesday, September 16, 2009 7:07 PM by sarma

How I can set object values dynamically . Because in my project url will be changing. So I can assign url dyanmically to object and How i can play it

# re: Streaming Audio Files in ASP.NET

Saturday, October 17, 2009 1:32 AM by himanshu

how can we change the file for playing at runtime

# re: Streaming Audio Files in ASP.NET

Saturday, November 28, 2009 1:57 AM by GJ

not working in Firefox...