Esempio n. 1
0
        public async void LoadFromSettings()
        {
            AnyListenSettings settings = AnyListenSettings.Instance;

            Playlists = settings.Playlists.Playlists;
            var currentState = settings.CurrentState;

            CSCoreEngine.EqualizerSettings = currentState.EqualizerSettings;
            CSCoreEngine.EqualizerSettings.Loaded();
            CSCoreEngine.Volume = currentState.Volume;
            DownloadManager     = settings.Config.Downloader;

            FavoritePlaylist = new FavoriteList();
            FavoritePlaylist.Initalize(Playlists);

            if (currentState.LastPlaylistIndex > -10)
            {
                CurrentPlaylist = IndexToPlaylist(currentState.LastPlaylistIndex);
            }

            SelectedPlaylist = IndexToPlaylist(currentState.SelectedPlaylist);

            if (currentState.SelectedTrack > -1 && currentState.SelectedTrack < SelectedPlaylist.Tracks.Count)
            {
                SelectedTrack = SelectedPlaylist.Tracks[currentState.SelectedTrack];
            }
            IsLoopEnabled    = currentState.IsLoopEnabled;
            IsShuffleEnabled = currentState.IsShuffleEnabled;
            foreach (NormalPlaylist lst in Playlists)
            {
                lst.LoadList();
            }
            FavoritePlaylist.LoadList();
            if (currentState.Queue != null)
            {
                Queue = currentState.Queue; Queue.Initialize(Playlists);
            }

            if (currentState.LastTrackIndex > -1 && currentState.LastTrackIndex < SelectedPlaylist.Tracks.Count)
            {
                PlayableBase t = CurrentPlaylist.Tracks[currentState.LastTrackIndex];
                if (t.TrackExists && currentState.TrackPosition >= 0)
                {
                    await CSCoreEngine.OpenTrack(t);

                    CSCoreEngine.Position = currentState.TrackPosition;
                    CSCoreEngine.OnPropertyChanged("Position");
                }
            }

            AsyncTrackLoader.Instance.RunAsync(Playlists.Cast <IPlaylist>().ToList());
        }
Esempio n. 2
0
        public void Loaded(MainWindow window)
        {
            _baseWindow = window;
            MySettings  = AnyListenSettings.Instance;

            MusicManager = new MusicManager();
            MusicManager.CSCoreEngine.TrackChanged          += CSCoreEngine_TrackChanged;
            MusicManager.CSCoreEngine.ExceptionOccurred     += CSCoreEngine_ExceptionOccurred;
            MusicManager.CSCoreEngine.SoundOutErrorOccurred += CSCoreEngine_SoundOutErrorOccurred;
            MusicManager.LoadFromSettings();
            MainTabControlIndex = MySettings.CurrentState.MainTabControlIndex;

            _keyboardListener          = new KeyboardListener();
            _keyboardListener.KeyDown += KListener_KeyDown;
        }