?
Solved

How To Play audio file in asp.net

Posted on 2014-07-13
3
Medium Priority
?
2,706 Views
Last Modified: 2014-08-03
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
0
Comment
Question by:Kamal Khaleefa
3 Comments
 
LVL 14

Accepted Solution

by:
quizwedge earned 1000 total points
ID: 40192751
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
 
LVL 54

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 1000 total points
ID: 40192968
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
 
LVL 16

Author Closing Comment

by:Kamal Khaleefa
ID: 40237365
Thank u all

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

thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month17 days, 3 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question