Hi, this question derives from my previous thread Play mp3 from internet without FileOpenDialog
I really hope someone knows anything about this. I was told to use a WebRequest to start a download stream and then play the stream instead of playing a locally stored file. However, trying to use the code from PlayMp3FromUrl gives me this error:
"'NAudio.Wave.WaveOut' does not contain a constructor that takes '3' arguments"
Compiling failes at this line:
using (WaveOut waveOut = new WaveOut(0, 500, null))
This is the full code:
public static void PlayMp3FromUrl(string url)
{
using (MemoryStream ms = new MemoryStream())
{
using (Stream stream = WebRequest.Create(url)
.GetResponse().GetResponseStream())
{
byte[] buffer = new byte[32768];
int read;
while ((read = stream.Read(buffer, 0, buffer.Length)) > 0)
{
ms.Write(buffer, 0, read);
}
}
ms.Position = 0;
using (WaveStream blockAlignedStream =
new BlockAlignReductionStream(
WaveFormatConversionStream.CreatePcmStream(
new Mp3FileReader(ms))))
{
using (WaveOut waveOut = new WaveOut(0, 500, null))
{
waveOut.Init(blockAlignedStream);
waveOut.Play();
while (blockAlignedStream.Position < blockAlignedStream.Length)
{
System.Threading.Thread.Sleep(100);
}
}
}
}
}
Can someone help me find out which arguments the WaveOut takes?
Edit: You probably want to look at the WaveOut.cs, and it's pretty long. So just have a look at it here WaveOut.cs