Change the bold red bits to your own values. If you want to set mywavfile.wav at runtime, put an <asp:Literal> control there and set its value programmatically.
Thanks,
Ganesh Rane
Don't forget to mark useful responses as Answer if they helped you towards a solution.
nd i dont want any other control of windows media player like stop, forward, pause etc.
just want a single button that starts the mp3 and runs till it ends....nd i want to give my own icon to all the image buttons..
Put an imagebutton control on your web page, you can set the ImageUrl to any your icon. And then set the onclientclick event to play the mp3 with embed tag like below:
ROHIT SOOD
Member
527 Points
448 Posts
play .mp3 file...
Aug 18, 2012 07:17 AM|LINK
hello every1
i want to play a mp3 file on an image button click....what is the best way to do this..
plz give code suggestions..
Regards
Rohit
ganesh.rane
Participant
1854 Points
318 Posts
Re: play .mp3 file...
Aug 18, 2012 08:07 AM|LINK
Try this
System.Diagnostics.Process.Start(Server.MapPath("") + @"\App_Code\preview.mp3");
Ganesh Rane
Don't forget to mark useful responses as Answer if they helped you towards a solution.
ROHIT SOOD
Member
527 Points
448 Posts
Re: play .mp3 file...
Aug 18, 2012 08:29 AM|LINK
hi ganesh..
the mp3 is playing but its playing through window media player...i want to
play the mp3 sound on image button click online in the background without showing any player...
like this...
http://www.aspnetaudio.com/aspnetaudio_Demonstration-Sound-Effects.aspx
In this link click on:
Missles.... like this i want to play the sound ...
Plz give some suggestion...
Regards
Rohit
ganesh.rane
Participant
1854 Points
318 Posts
Re: play .mp3 file...
Aug 18, 2012 10:56 AM|LINK
<object id="MediaPlayer1" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
Change the bold red bits to your own values. If you want to set mywavfile.wav at runtime, put an <asp:Literal> control there and set its value programmatically.
Ganesh Rane
Don't forget to mark useful responses as Answer if they helped you towards a solution.
ROHIT SOOD
Member
527 Points
448 Posts
Re: play .mp3 file...
Aug 18, 2012 12:58 PM|LINK
ok its working fine....but i want to play 9 mp3's on 9 different image buttons....
nd i dont want any other control of windows media player like stop, forward, pause etc.
just want a single button that starts the mp3 and runs till it ends....nd i want to give my own icon to all the image buttons..
Plz give suggestions,,.,everything else is working correctly...
Damn Code
Participant
1883 Points
323 Posts
Re: play .mp3 file...
Aug 18, 2012 01:06 PM|LINK
Hi, friend
Have a look at this old post that addresses about the same case. hope get help.
http://forums.asp.net/t/1303198.aspx
Please remember to Mark the replies as Answers if they help & unmark them if they provide no help.
ROHIT SOOD
Member
527 Points
448 Posts
Re: play .mp3 file...
Aug 20, 2012 04:41 AM|LINK
hello every1
iam using this code to play the audio file... its working fine...
.but i want to play 9 mp3's on 9 different image buttons....
nd i dont want any other control of windows media player like stop, forward, pause etc.
just want a single button that starts the mp3 and runs till it ends....nd i want to give my own icon to all the image buttons..
Plz help with the solution...
.....
<object id="Object1" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
standby="Loading Microsoft Windows® Media Player components..."
type="application/x-oleobject" width="150" height="35">
<param name="fileName" value="a.mp3" />
<param name="animationatStart" value="true" />
<param name="transparentatStart" value="true" />
<param name="autoStart" value="false" />
<param name="Volume" value="-450" />
<param name="DisplayBackColor" value="0">
<param name="DisplayForeColor" value="16777215">
<param name="EnableFullScreenControls" value="0">
<param name="PlayCount" value="none">
<param name="ShowControls" value="none">
<embed type="application/x-mplayer2"
pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"
src="a.mp3" name="MediaPlayer1"
width="150" height="35" autostart="false" showcontrols="1" volume="-450">
</object>
Mamba Dai - ...
All-Star
23531 Points
2683 Posts
Microsoft
Re: play .mp3 file...
Aug 22, 2012 06:30 AM|LINK
Hi,
Put an imagebutton control on your web page, you can set the ImageUrl to any your icon. And then set the onclientclick event to play the mp3 with embed tag like below:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <script type="text/javascript"> function Play() { document.write('<embed src="Sleep Away.mp3" type="audio/mp3" style="display:none" />'); } </script> <img <img src="play.JPG" onclick="Play();" /> <asp:ImageButton ID="ibtnPlay" runat="server" ImageUrl="~/play.JPG" OnClientClick="Play()" /> </div> </form> </body> </html>Feedback to us
Develop and promote your apps in Windows Store