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:




  1. load an mp3 record url memorystream

  2. convert mp3 information call information after totally loaded

  3. 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

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?