public static CMp3Frame LoadFromBytes(BufferedData input) { var frame = new CMp3Frame(); byte[] headerBytes = new byte[4]; int bytesRead = input.Read(headerBytes, 0, headerBytes.Length); if (bytesRead == 0) { return(null); } while (!IsValidHeader(headerBytes, frame)) { headerBytes[0] = headerBytes[1]; headerBytes[1] = headerBytes[2]; headerBytes[2] = headerBytes[3]; bytesRead = input.Read(headerBytes, 3, 1); if (bytesRead == 0) { return(null); } } int bytesRequired = frame.FrameLength - 4; frame.RawData = new byte[frame.FrameLength]; Array.Copy(headerBytes, frame.RawData, 4); bytesRead = input.Read(frame.RawData, 4, bytesRequired); if (bytesRead == 0) { return(null); } return(frame); }
public void Play(double pVolumeValue) { if (playbackState == StreamingPlaybackState.Stopped) { playbackState = StreamingPlaybackState.Buffering; bufferedWaveProvider = null; _bufferedData = new BufferedData(65536); ThreadPool.QueueUserWorkItem(Mp3Running); ThreadPool.QueueUserWorkItem(PlayingMp3, pVolumeValue); } else if (playbackState == StreamingPlaybackState.Paused) { playbackState = StreamingPlaybackState.Buffering; } }