How To Play audio file in asp.net

Dear EE,

i have uploaded some audio files to my site with extension ".WMA"

i want when the user click a button to play the audio file , to open a small popup windows and display the windows media players inside it and play the sound

Thanks
LVL 16
Kamal KhaleefaInformation Security SpecialistAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

quizwedgeCommented:
I'd recommend mp3 over WMA since it's more cross platform compatible. That being said, check out http://www.mediacollege.com/video/format/windows-media/streaming/embed.html for embedding audio files.

In case that site goes down, the summary is:

The example below shows the code for embedding a Windows Media file. Note that it uses two tags: <object> and <embed>. This is to enable maximum browser compatibility.You will need to set the file name (and other attributes if required) for both tags. Use true or false for the <object> tag, 1 or 0 for the <embed> tag.

Code for HTML5:

<object id="MediaPlayer" width="192" height="190" type="video/x-ms-asf">
<param name="FileName"value="videofilename.wmv">
<param name="autostart" value="false">
<param name="ShowControls" value="true">
<param name="ShowStatusBar" value="false">
<param name="ShowDisplay" value="false">
<embed type="application/x-mplayer2" src="videofilename.wmv"
width="192" height="190" ShowControls="1" ShowStatusBar="0" ShowDisplay="0" autostart="0" />
</object>
Code for HTML 4.01:

<OBJECT ID="MediaPlayer" WIDTH="192" HEIGHT="190" CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
STANDBY="Loading Windows Media Player components..." TYPE="application/x-oleobject">
<PARAM NAME="FileName" VALUE="videofilename.wmv">
<PARAM name="autostart" VALUE="false">
<PARAM name="ShowControls" VALUE="true">
<param name="ShowStatusBar" value="false">
<PARAM name="ShowDisplay" VALUE="false">
<EMBED TYPE="application/x-mplayer2" SRC="videofilename.wmv" NAME="MediaPlayer"
WIDTH="192" HEIGHT="190" ShowControls="1" ShowStatusBar="0" ShowDisplay="0" autostart="0"> </EMBED>
</OBJECT>
To get started, all you have to do is copy the code above into your web page and replace videofilename.wmv with your own file name.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
This is really a front end thing and not .NET.

The audio tag can be easily used and is available on modern browsers (ie9+) http://caniuse.com/audio

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio
<!-- Simple audio playback -->
<audio src="http://developer.mozilla.org/@api/deki/files/2926/=AudioTest_(1).ogg" autoplay>
  Your browser does not support the <code>audio</code> element.
</audio>

<!-- Audio playback with captions -->
<audio src="foo.ogg">
  <track kind="captions" src="foo.en.vtt" srclang="en" label="English">
  <track kind="captions" src="foo.sv.vtt" srclang="sv" label="Svenska">
</audio>

Open in new window

There are js projects like http://kolber.github.io/audiojs/ or you can use video projects for audio only https://flowplayer.org/.  With flowplayer you can fall back to flash if you want to support ie8 and  below and there is an html5 player as well.  No need to support ie8 anymore in my opinion.
0
Kamal KhaleefaInformation Security SpecialistAuthor Commented:
Thank u all

what i did that i convert all the wma files i have to mp3 and then use the code

thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.