play audio tide controlling c#
is there proceed c# play audio (for example, mp3) direcly instance returend webrequest but saving information temporarily disk?
solution
with assistance 1.3 illusory to:
- load an mp3 record url memorystream
- convert mp3 information call information after totally loaded
- playback call information controlling 's waveout class
it have good means even play half hallowed mp3 file, nonetheless seems dilettante due library design.
and duty work:
open stationary vacant playmp3fromurl(string url)
{
controlling (stream ms = new memorystream())
{
controlling (stream tide = webrequest.create(url)
.getresponse().getresponsestream())
{
byte[] aegis = new byte[32768];
int read;
while ((read = stream.read(buffer, 0, buffer.length)) > 0)
{
ms.write(buffer, 0, read);
}
}
ms.position = 0;
controlling (wavestream blockalignedstream =
new blockalignreductionstream(
waveformatconversionstream.createpcmstream(
new mp3filereader(ms))))
{
controlling (waveout waveout = new waveout(wavecallbackinfo.functioncallback()))
{
waveout.init(blockalignedstream);
waveout.play();
while (waveout.playbackstate == playbackstate.playing )
{
system.threading.thread.sleep(100);
}
}
}
}
}
Comments
Post a Comment