Ejemplo n.º 1
0
        private async Task InitializeAudioGraphAsync()
        {
            _audioPlayer = new XAudioPlayer();

            var successful = await _audioPlayer.InitializeAudioGraphAsync();

            if (!successful)
            {
                IsAudioEffectsSupport = false;
                return;
            }

            IsAudioEffectsSupport         = true;
            _audioPlayer.MediaEnd        += (sender, args) => OnCurrentTrackEnd();
            _audioPlayer.StateChanged    += (sender, args) => DispatcherHelper.CheckBeginInvokeOnUI(() => State = _audioPlayer.State);
            _audioPlayer.ErrorOccurred   += (sender, args) => OnCurrentTrackEnd();
            _audioPlayer.PositionChanged += (sender, args) => DispatcherHelper.CheckBeginInvokeOnUI(() => NotifyPositionInternal(_audioPlayer.Position));

            _audioPlayer.IsEQEffectEnabled = LocalSettingsHelper.LoadValue(CommonKeys.EQEffectEnabled, false);
            _audioPlayer.EQBassGain        = LocalSettingsHelper.LoadValue(CommonKeys.EQBassGain, 50d);
            _audioPlayer.EQLowMidGain      = LocalSettingsHelper.LoadValue(CommonKeys.EQLowMidGain, 20d);
            _audioPlayer.EQHighMidGain     = LocalSettingsHelper.LoadValue(CommonKeys.EQHighMidGain, 70d);
            _audioPlayer.EQHighPitchGain   = LocalSettingsHelper.LoadValue(CommonKeys.EQHighPitchGain, 30d);

            _audioPlayer.IsEchoEffectEnabled = LocalSettingsHelper.LoadValue(CommonKeys.EchoEffectEnabled, false);
            _audioPlayer.EchoDelay           = LocalSettingsHelper.LoadValue(CommonKeys.EchoDelay, 50d);

            _audioPlayer.IsLimiterEffectEnabled = LocalSettingsHelper.LoadValue(CommonKeys.LimiterEffectEnabled, false);
            _audioPlayer.LimiterLoudness        = LocalSettingsHelper.LoadValue(CommonKeys.LimiterLoudness, 20u);

            _audioPlayer.IsReverbEffectEnabled = LocalSettingsHelper.LoadValue(CommonKeys.ReverbEffectEnabled, false);
            _audioPlayer.ReverbDecayTime       = LocalSettingsHelper.LoadValue(CommonKeys.ReverbDecay, 2d);
        }
Ejemplo n.º 2
0
        public async Task InitializeAsync()
        {
            if (_initialized)
            {
                return;
            }
            _initialized = true;

            if (LocalSettingsHelper.LoadValue(CommonKeys.KeepScreenOn, false))
            {
                DisplayRequestHelper.RequestActive();
            }

            PlaylistsTitle = new ObservableCollection <string>((await Playlist.GetPlaylistsTitleAsync()));

            var lastUsedPlaylist = LocalSettingsHelper.LoadValue(CommonKeys.LastUsedPlaylist, PlaylistsTitle.FirstOrDefault());

            _selectedPlaylistTitle = PlaylistsTitle.SingleOrDefault(p => p.Equals(lastUsedPlaylist, StringComparison.OrdinalIgnoreCase)) ?? PlaylistsTitle.FirstOrDefault();
            RaisePropertyChanged(nameof(SelectedPlaylistTitle));
            await SwitchPlaylist(SelectedPlaylistTitle);

            if (ActivePlaylistViewModel == null)
            {
                return;
            }

            var lastPlayedSong = LocalSettingsHelper.LoadValue(CommonKeys.LastPlayedSong, string.Empty);

            if (string.IsNullOrEmpty(lastPlayedSong))
            {
                return;
            }

            var songs = ActivePlaylistViewModel.GetFlatSongs();

            if (songs.Count == 0)
            {
                return;
            }
            var targetSong = songs.FirstOrDefault(s => s.FileUriPath.Equals(lastPlayedSong, StringComparison.OrdinalIgnoreCase));

            if (targetSong == null)
            {
                return;
            }

            PlayerViewModel.PlaylistTitle = ActivePlaylistViewModel.Title;

            if (((App)Application.Current).IsFileActivated)
            {
                return;
            }

            PlayerViewModel.AutoPlay = LocalSettingsHelper.LoadValue(CommonKeys.AutoPlay, false);
            PlayerViewModel.Play(songs, songs.IndexOf(targetSong));
        }
Ejemplo n.º 3
0
        public SleepingModeViewModel()
        {
            _userDefinedNumber = LocalSettingsHelper.LoadValue(CommonKeys.SleepingModeNumber, (uint)30).ToString();
            _isMinutesMode     = LocalSettingsHelper.LoadValue(CommonKeys.SleepingMinutesMode, true);
            _isSongsCountMode  = LocalSettingsHelper.LoadValue(CommonKeys.SleepingSongsCountMode, false);

            StartCommand = new ActionCommand <object>(ExecuteStartCommand);

            ViewModelLocator.Instance.PlayerViewModel.ActiveSongChanged += PlayerViewModelOnActiveSongChanged;
        }
Ejemplo n.º 4
0
        public async Task InitializeAsync()
        {
            if (_initialized)
            {
                return;
            }
            _initialized = true;

            _isLoopOn         = LocalSettingsHelper.LoadValue(CommonKeys.IsLoopOn, false);
            _isShuffleOn      = LocalSettingsHelper.LoadValue(CommonKeys.IsShuffleOn, false);
            _isSingleRepeatOn = LocalSettingsHelper.LoadValue(CommonKeys.IsSingleRepeatOn, false);

            await InitializeAudioGraphAsync();
        }
Ejemplo n.º 5
0
        public AudioEffectsViewModel()
        {
            _isEqualizerEnabled = LocalSettingsHelper.LoadValue(CommonKeys.EQEffectEnabled, false);
            _isEchoEnabled      = LocalSettingsHelper.LoadValue(CommonKeys.EchoEffectEnabled, false);
            _isLimiterEnabled   = LocalSettingsHelper.LoadValue(CommonKeys.LimiterEffectEnabled, false);
            _isReverbEnabled    = LocalSettingsHelper.LoadValue(CommonKeys.ReverbEffectEnabled, false);

            _echoDelay       = PlayerViewModel.XAudioPlayer?.EchoDelay ?? 50;
            _limiterLoudness = PlayerViewModel.XAudioPlayer?.LimiterLoudness ?? 20;
            _reverbDecayTime = PlayerViewModel.XAudioPlayer?.ReverbDecayTime ?? 2;
            _eq100HzGain     = PlayerViewModel.XAudioPlayer?.EQBassGain ?? 50;
            _eq900HzGain     = PlayerViewModel.XAudioPlayer?.EQLowMidGain ?? 20;
            _eq5kHzGain      = PlayerViewModel.XAudioPlayer?.EQHighMidGain ?? 70;
            _eq12kHzGain     = PlayerViewModel.XAudioPlayer?.EQHighPitchGain ?? 30;
        }
Ejemplo n.º 6
0
 public SettingsViewModel()
 {
     _autoPlay     = LocalSettingsHelper.LoadValue(CommonKeys.AutoPlay, false);
     _keepScreenOn = LocalSettingsHelper.LoadValue(CommonKeys.KeepScreenOn, false);
 }