5
다운로드를 시작할 때 원격 mp3 파일의 재생 시간 정보를 얻고 싶습니다. 나는 처음에는 프레임을 얻을 수 있지만 어느 것이 읽혀 져야하는지, 싱 (Xing) 또는 브이 브리 (VBRi)인지 알지 못합니다.전체 파일을 다운로드하지 않고 VBR mp3에 대한 BitRate를 계산하는 방법은 무엇입니까?
태그를 읽음으로써 어떻게 정보를 얻을 수 있습니까?
MemoryStream ms = new MemoryStream();
waveOut.Play();
long offset = from;
ms.Position = 0;
byte[] decBuffer = new byte[50 * 1024];
while (true)
{
if (paused)
{
waveOut.Stop();
bwProvider.ClearBuffer();
break;
}
lock (LockObj)
{
byte[] readed = Helper.ReadStreamPartially(localStream, offset, 100 * 1024, orders);
if (readed == null)
continue;
ms = new MemoryStream(readed);
}
Mp3Frame frame;
try
{
frame = Mp3Frame.LoadFromStream(ms);
}
catch
{
continue;
}
if (frame == null)
continue;
int decompressed = decompressor.DecompressFrame(frame, decBuffer, 0);
bwProvider.AddSamples(decBuffer, 0, decompressed);
if (Helper.IsBufferNearlyFull(bwProvider))
Thread.Sleep(500);
offset += ms.Position;
}
http://stackoverflow.com/q/9046492/1070452 – Plutonix
어쩌면이 당신을 도와줍니다 - https://www.mp3-tech.org/programmer/frame_header.html 및 http://mpgedit.org/ mpgedit/mpeg_format/mpeghdr.htm –
여기 좀보세요 http://stackoverflow.com/questions/6196011/how-to-read-xingheaders-and-vbriheaders-from-mp3-files-using-taglib-sharp –