Пример #1
0
        public async System.Threading.Tasks.Task ApplyEqualizer(Equalizer.Band[] bands, AVPlayerItem item)
        {
            Bands = bands ?? new Equalizer.Band[0];
            if (item == null)
            {
                return;
            }
            if (item.Tracks.Length == 0)
            {
                await item.WaitLoadTracks();
            }
            var audio = item.Tracks.FirstOrDefault(x => x.AssetTrack.HasMediaCharacteristic(AVMediaCharacteristic.Audible));

            if (audio == null)
            {
                return;
            }
            if (processor == null || processor?.audioAssetTrack != audio.AssetTrack)
            {
                processor?.Dispose();
                processor = new AudioTapProcessor(audio.AssetTrack)
                {
                    Parent = this,
                    IsBandpassFilterEnabled = Active,
                };
            }

            processor.IsBandpassFilterEnabled = StateManager.Shared.EqualizerEnabled;
            item.AudioMix = processor.AudioMix;
            for (int i = 0; i < Bands.Count(); i++)
            {
                UpdateBand(i, Bands[i].Gain);
            }
        }