Mp3Sharp.StreamedSound.OnBufferNotification C# (CSharp) Method

OnBufferNotification() public method

public OnBufferNotification ( object sender, BufferNotificationEventArgs e ) : void
sender object
e BufferNotificationEventArgs
return void
        public void OnBufferNotification(object sender, BufferNotificationEventArgs e)
        {
            if (e.NewSoundByte == null || e.NewSoundByte.Length != e.NumBytesRequired)
                e.NewSoundByte = new byte[e.NumBytesRequired];

            int bytesRead = Stream.Read(e.NewSoundByte, 0, e.NumBytesRequired);
            if (bytesRead != e.NumBytesRequired)
            {
                byte[] trimmedBytes = new byte[bytesRead];
                Array.Copy(e.NewSoundByte, trimmedBytes, bytesRead);
                e.NewSoundByte = trimmedBytes;
            }
            e.SoundFinished = Stream.Length == Stream.Position;

            if (BufferNotification != null) BufferNotification(sender, e);
        }