Esempio n. 1
0
        /// <summary>
        /// Creates a new instance of the <see cref="Mp3Frame"/> class based on a <see cref="Stream"/>.
        /// </summary>
        /// <param name="stream"><see cref="Stream"/> which provides MP3 data.</param>
        /// <param name="data">Byte array which recieves the content of the <see cref="Mp3Frame"/>.</param>
        /// <returns>A new instance of the <see cref="Mp3Frame"/> class based on the specified <paramref name="stream"/>.</returns>
        public static Mp3Frame FromStream(Stream stream, ref byte[] data)
        {
            Mp3Frame frame = new Mp3Frame(stream);

            if (frame.FindFrame(stream, false))
            {
                data = data.CheckBuffer(frame.FrameLength);
                Array.Copy(frame._headerBuffer, 0, data, 0, 4);
                int read = stream.Read(data, 4, frame.FrameLength - 4);
                if (read != frame.FrameLength - 4)
                {
                    return(null);
                }

                return(frame);
            }

            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new instance of the <see cref="Mp3Frame"/> class based on a <see cref="Stream"/>.
        /// </summary>
        /// <param name="stream"><see cref="Stream"/> which provides MP3 data.</param>
        /// <returns>A new instance of the <see cref="Mp3Frame"/> class based on the specified <paramref name="stream"/>.</returns>
        public static Mp3Frame FromStream(Stream stream)
        {
            Mp3Frame frame = new Mp3Frame(stream);

            return(frame.FindFrame(stream, stream.CanSeek) ? frame : null);
        }