Binding _soundOut.WaveSource.Position to slider

Dec 30, 2014 at 11:19 AM
How to bind _soundOut.WaveSource.Position to slider? Example please) ty
Coordinator
Jan 3, 2015 at 9:12 AM
The property changes by reading from the source. In your case this is done by the soundout. The NotificationSource provides an event which gets fired after a specified period. Just a little example:
    class AudioPlayer : INotifyPropertyChanged
    {
        private IWaveSource _source;
        private WasapiOut _soundOut;

        public long Position
        {
            get
            {
                if (_source != null)
                    return _source.Position;
                return 0;
            }
        }

        public void Play(string filename)
        {
            //...
            _soundOut = new WasapiOut();
            _source = CodecFactory.Instance.GetCodec(filename);
            var notificationSource = new NotificationSource(_source);
            notificationSource.Interval = 100; //100 ms
            notificationSource.BlockRead += (s, e) =>
            {
                var copy = PropertyChanged;
                if (copy != null)
                {
                    copy(this, new PropertyChangedEventArgs("Position"));
                }
            };

            //...
            IWaveSource finalWaveSource = notificationSource.ToWaveSource();

            _soundOut.Initialize(finalWaveSource);

            //...
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }
Jan 3, 2015 at 11:05 AM
Edited Jan 4, 2015 at 2:45 PM
don't works((