Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
hello i'm trying to develop chat facility, in which i use one 2 textbox and one button1.
whenver the user enter the message in one textbox by clicking button, then a sound will be dispaly during the message display in another textbox(say textbox2)
 
so can u help me in solving the problm...
Posted 5-Jan-13 5:08am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
If your sound file is a .wav file, you can try this:
protected void button1_Click(object sender, EventArgs e)
{
     byte[] result = System.IO.File.ReadAllBytes("sound.wav");
     System.IO.MemoryStream ms = new System.IO.MemoryStream(result);
     ms.Position = 0;
     System.Media.SoundPlayer soundPlayer = new System.Media.SoundPlayer(ms);
     soundPlayer.PlayLooping(); // play the sound file
     // now, display the message in the other textbox
     soundPlayer.Stop(); // stop playing the sound
}
If your audio file isn't a .wav file, then have a look here:
http://www.crowsprogramming.com/archives/58[^]
You can also convert your audio file to a .wav file.
Have a look at this list of audio conversion software[^].
 
Hope this helps.
  Permalink  
v5
Comments
Cto Manav Parasrampuria at 5-Jan-13 10:38am
   
not work...error message show:
 
The wave header is corrupt.
 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
 
Exception Details: System.InvalidOperationException: The wave header is corrupt.
 
Source Error:
 

Line 18:
Line 19: System.Media.SoundPlayer soundPlayer = new System.Media.SoundPlayer("http://localhost:13769/ASPNETCHAT/sound.au");
Line 20: soundPlayer.PlayLooping(); // play the sound filehttp:
Line 21: // now, display the message in the other textbox
Line 22: soundPlayer.Stop(); // stop playing the sound
ProgramFOX at 5-Jan-13 10:43am
   
Hi,
I updated my answer.
Cto Manav Parasrampuria at 5-Jan-13 11:22am
   
hello...not worked,,,,following error display
 
URI formats are not supported.
 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
 
Exception Details: System.ArgumentException: URI formats are not supported.
 
Source Error:
 

Line 16: protected void Button1_Click(object sender, EventArgs e)
Line 17: {
Line 18: byte[] result = System.IO.File.ReadAllBytes("http://localhost:13769/ASPNETCHAT/sound.au");
Line 19: System.IO.MemoryStream ms = new System.IO.MemoryStream(result);
Line 20: ms.Position = 0;
ProgramFOX at 5-Jan-13 11:27am
   
Change
byte[] result = System.IO.File.ReadAllBytes("http://localhost:13769/ASPNETCHAT/sound.au");
into
byte[] result = System.IO.File.ReadAllBytes(Server.MapPath("/ASPNETCHAT/sound.au"));
But this will only work for .wav files. I'll try to find a solution for a .au file.
ProgramFOX at 5-Jan-13 11:31am
   
It's possible to convert your .au file to a .wav file. There're a lot of audio converters. Here's a list of audio conversion software.
Cto Manav Parasrampuria at 5-Jan-13 11:24am
   
is this only work for .wav extension file....it is required to use that extension file ..ya i can use any extension file...please review my above problem
Cto Manav Parasrampuria at 5-Jan-13 11:33am
   
okey..i think the problem is extension....thank you replying...i'll wait of your answer..... a
ProgramFOX at 5-Jan-13 11:34am
   
I updated my answer. I added a list of audio conversion software.
Cto Manav Parasrampuria at 5-Jan-13 11:39am
   
thnak You..one more question:
 
hello i have a chatting.cs file in which i want to bold the user name..i'm using below code but its not workin....

string myuser="" + User + " ";

can you help me to correct the code so that i can bold the user name...i'm not applynig html encoded but it not working:
 
this result come.. : user
ProgramFOX at 5-Jan-13 11:43am
   
Hi,
I saw your question here.
I agree with Zoltán Zörgő. I didn't find another answer, I'm sorry.
Cto Manav Parasrampuria at 5-Jan-13 12:00pm
   
but i'm not use any html encode code..so how can i solve......
ProgramFOX at 5-Jan-13 12:01pm
   
Do you mean that you want to use bold text in your code file?
Cto Manav Parasrampuria at 5-Jan-13 13:25pm
   
yeah..i want that "user" should be bold in .cs file ....
ProgramFOX at 5-Jan-13 13:27pm
   
Not possible. A C# file is just text, no markup. Visual Studio highlights text. And Visual Studio highlights only keywords, classes and digits.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 200
1 George Jonsson 175
2 Kornfeld Eliyahu Peter 169
3 PIEBALDconsult 110
4 Richard MacCutchan 85
0 OriginalGriff 6,080
1 DamithSL 4,648
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,624
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 5 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100