private static void OnAdvancedControlsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            AudioOutWPF target = (AudioOutWPF)d;

            bool newValue = (bool)e.NewValue;

            if (newValue)
            {
                var selected = target.SelectedOutput;
                target.InitializeOutputDevices();
                var found = OutputList.FirstOrDefault(m => m.Guid == selected.Guid && m.Provider == selected.Provider);
                if (found != null)
                {
                    target.SelectedOutput = found;
                }
            }
            else
            {
                target.UseWaveEvent = false;
                target.SetValue(ShouldRampUnderrunsProperty, false);

                var selected = target.SelectedOutput;
                var toRemove = OutputList.Where(m => m.MMDevice == null && m != selected).ToList();
                foreach (var item in toRemove)
                {
                    OutputList.Remove(item);
                }
            }

            foreach (UserAudioPlayerWPF player in AudioPlayers)
            {
                player.SetValue(UserAudioPlayerWPF.ShowAdvancedControlsProperty, newValue);
            }
        }
Example #2
0
        internal UserAudioPlayerWPF(Guid userID, AudioOutWPF parent, bool useWaveEvent = true)
            : this()
        {
            Player      = new UserAudioPlayer(userID, parent, useWaveEvent);
            DataContext = Player;
            InitializeComponent();

            Player.VisSource.LevelDbChanged += OnLevelDbChanged;
        }
        internal UserAudioPlayerWPF(Guid userID, AudioOutWPF parent, bool useWaveEvent = true)
            : this()
        {
            Player = new UserAudioPlayer(userID, parent, useWaveEvent);
            DataContext = Player;
            InitializeComponent();

            Player.VisSource.LevelDbChanged += OnLevelDbChanged;
        }
        public UserAudioPlayer(Guid userID, AudioOutWPF parent, bool useWaveEvent = true)
        {
            if (!DesignerProperties.GetIsInDesignMode(this))
                new CompositionContainer(new AssemblyCatalog(Assembly.GetExecutingAssembly())).ComposeParts(this);

            Parent = parent;
            this.UserID = userID;
            UseWaveEvent = useWaveEvent;

            User = UserStatusRepo.FindUser(userID);
            UserStatusRepo.Users.CollectionChanged += Users_CollectionChanged;

            aggregator = new FeenPhone.Audio.SampleAggregator() { PerformFFT = false };
            aggregator.NotificationCount = 882;
            aggregator.PerformFFT = true;

            VisSource = new AudioVisualizationSource(aggregator);

            LastReceived = DateTime.UtcNow;
        }