Use HTML5 to achieve this. It supports WAV files :)
Take a look at this: http://www.w3schools.com/html/html5_audio.asp
NOTE: Be aware that not all browsers support WAV files. You'll find more details on that page!
Domanda
How to play wav file format (A-Law, 8000 Hz, 64 Kbps, mono ) in c# asp.net web forms.
c# asp.net supports only to play wav PCM format
Soluzione
Use HTML5 to achieve this. It supports WAV files :)
Take a look at this: http://www.w3schools.com/html/html5_audio.asp
NOTE: Be aware that not all browsers support WAV files. You'll find more details on that page!
Altri suggerimenti
It is extremely difficult to create your own a-law player, this will require deep understanding of the algorithm . fortunately there are tools out there such as SoX to help you convert that file to the desired .wav
format.
Here 's a function I wrote to convert files u-law
files to wav format so I could read it
/// <summary>
/// Generates the sound file using SoX.exe.
/// </summary>
/// <param name="fromFile">From file in uLaw encoding.</param>
/// <param name="toFile">To wav file.</param>
public bool GenerateSoundFile(string fromFile, string toFile)
{
string log = string.Format("fromFile={0},toFile={1}", fromFile, toFile);
//EventLogger.Log(log);
string arguments;
//check the extension
string ext = Path.GetExtension(fromFile);
if (ext == ".ulaw")
{
arguments = string.Format("-t ul {0} -c 1 -r 8000 {1}", fromFile, toFile);
}
else
{
arguments = string.Format(" {0} -c 1 -r 8000 {1}", fromFile, toFile);
}
//EventLogger.Log(arguments);
string command = System.Environment.CurrentDirectory + "\\sox.exe";
try
{
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = command;
p.StartInfo.Arguments = arguments;
p.StartInfo.LoadUserProfile = true;
p.Start();
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
}
catch (Exception e)
{
EventLogger.Error("GenerateSoundFile", e);
}
//check output file exists
if (!File.Exists(toFile))
{
//EventLogger.Error("No output sound file generated");
return false;
}
else
{
return true;
}
}