Esempio n. 1
0
        public void Start()
        {
            _saveStream = File.OpenRead(SavePath);

            _audioPlayback = new AudioPlayback(SampleRate, Channel, SampleType);

            _audioPlayback.StateChanged += (s, e) =>
                                           StateChanged?.Invoke(this, new StateChangedEventArgs((State)e.Current));

            _audioPlayback.Prepare();

            _audioPlayback.BufferAvailable += (s, e) =>
            {
                if (_saveStream.Position == _saveStream.Length)
                {
                    return;
                }

                var buf = new byte[e.Length];
                _saveStream.Read(buf, 0, buf.Length);
                _audioPlayback.Write(buf);
            };

            // Or you can write at once.
            // _audioPlayback.Write(File.ReadAllBytes(SavePath));
        }