Dec 25, 2012 at 2:24 PM
Edited Dec 25, 2012 at 4:30 PM
|
Hello. My english bad, sorry.
I need help with my player.
I have link "http://cs5880.userapi.com/u9002353/audios/5080e5649b40.mp3" (example)
How i can play this track in real-time? (after 100-500ms? +-)
private MemoryStream ms;
private WaveOut waveOut;
It's first thread:
using (var stream = WebRequest.Create(url).GetResponse().GetResponseStream())
{
byte[] buffer = new byte[1024*64];
int read;
while ((read = stream.Read(buffer, 0, buffer.Length)) > 0)
{
var pos = ms.Position;
ms.Position = ms.Length;
ms.Write(buffer, 0, read);
ms.Position = pos;
}
Last thread:
ms.Position = 0;
using (var mp3FileReader = new Mp3FileReader(ms))
using (var waveFormatConv = WaveFormatConversionStream.CreatePcmStream(mp3FileReader))
using (var blockAlignedStream = new BlockAlignReductionStream(waveFormatConv))
{
waveOut = new WaveOut();
waveOut.Init(blockAlignedStream);
waveOut.Play();
while (!taskWaveStop)
{
Thread.Sleep(1 0);
}
}
But id3tag always in random position. If position of tag > my buffer, then i will be have random error.
What i do?
|