Ejemplo n.º 1
0
 public virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         CSCoreEngine.Dispose();
     }
 }
Ejemplo n.º 2
0
        public async void GoForward()
        {
            if (CurrentPlaylist == null || CurrentPlaylist.Tracks.Count == 0)
            {
                return;
            }
            PlayableBase nextTrack;

            if (Queue.HasTracks)
            {
                var tuple = Queue.PlayNextTrack();
                nextTrack       = tuple.Item1;
                CurrentPlaylist = tuple.Item2;
            }
            else
            {
                int currenttrackindex = CurrentPlaylist.Tracks.IndexOf(CSCoreEngine.CurrentTrack);
                int nexttrackindex    = currenttrackindex;
                if (CheckIfTracksExists(CurrentPlaylist))
                {
                    if (IsShuffleEnabled)
                    {
                        nextTrack = CurrentPlaylist.GetRandomTrack(CSCoreEngine.CurrentTrack);
                        if (nextTrack == null)
                        {
                            return;
                        }
                    }
                    else
                    {
                        while (true)
                        {
                            nexttrackindex++;
                            if (CurrentPlaylist.Tracks.Count - 1 < nexttrackindex)
                            {
                                nexttrackindex = 0;
                            }
                            if (CurrentPlaylist.Tracks[nexttrackindex].TrackExists)
                            {
                                break;
                            }
                        }
                        nextTrack = CurrentPlaylist.Tracks[nexttrackindex];
                    }
                }
                else
                {
                    return;
                }
            }
            if (nextTrack.TrackExists)
            {
                if (await CSCoreEngine.OpenTrack(nextTrack))
                {
                    CSCoreEngine.TogglePlayPause();
                }
            }
        }
Ejemplo n.º 3
0
        public MusicManager()
        {
            _tempHistory = new List <Tuple <IPlaylist, IPlayable> >();
            AudioEngine  = new CSCoreEngine();
            AudioEngine.TrackFinished += AudioEngineOnTrackFinished;
            AudioEngine.EqualizerBands = new EqualizerBandCollection();
            Queue = new Queue();

            AudioEngine.CrossfadeDuration = TimeSpan.FromSeconds(4);
            IsCrossfadeEnabled            = true;
        }
Ejemplo n.º 4
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());
        }
Ejemplo n.º 5
0
 async void CSCoreEngine_TrackFinished(object sender, EventArgs e)
 {
     if (IsLoopEnabled)
     {
         if (await CSCoreEngine.OpenTrack(CSCoreEngine.CurrentTrack))
         {
             CSCoreEngine.TogglePlayPause();
         }
     }
     else
     {
         GoForward();
     }
 }
Ejemplo n.º 6
0
        public async void PlayTrack(PlayableBase track, IPlaylist playlist)
        {
            CSCoreEngine.StopPlayback();

            if (Queue.HasTracks && Queue.FirstOrDefault(t => t.TrackId == track.AuthenticationCode) != null)
            {
                Queue.RemoveTrack(track);
            }

            if (await CSCoreEngine.OpenTrack(track))
            {
                CSCoreEngine.TogglePlayPause();
                CurrentPlaylist = playlist;
            }
        }
Ejemplo n.º 7
0
        public MusicManager()
        {
            CSCoreEngine = new CSCoreEngine();
            Playlists    = new ObservableCollection <NormalPlaylist>();
            CSCoreEngine.TrackFinished += CSCoreEngine_TrackFinished;
            CSCoreEngine.TrackChanged  += CSCoreEngine_TrackChanged;
            Notification = new NotificationService(CSCoreEngine);
            Commands     = new MusicManagerCommands(this);

            Random          = new Random();
            Lasttracks      = new List <TrackPlaylistPair>();
            Queue           = new QueueManager();
            DownloadManager = new DownloadManager();
            TrackSearcher   = new TrackSearcher(this, (MainWindow)Application.Current.MainWindow);
        }
Ejemplo n.º 8
0
        public async void GoBackward()
        {
            if (CurrentPlaylist == null || CurrentPlaylist.Tracks.Count == 0)
            {
                return;
            }
            PlayableBase newtrack;

            if (Lasttracks.Count > 1) //Check if there are more than two tracks, because the current track is the last one in the list
            {
                Lasttracks.Remove(Lasttracks.Last(x => x.Track == CSCoreEngine.CurrentTrack));
                newtrack        = Lasttracks.Last().Track;
                CurrentPlaylist = Lasttracks.Last().Playlist;
            }
            else
            {
                int currenttrackindex = CurrentPlaylist.Tracks.IndexOf(CSCoreEngine.CurrentTrack);
                int nexttrackindex    = currenttrackindex;
                if (CheckIfTracksExists(CurrentPlaylist))
                {
                    while (true)
                    {
                        nexttrackindex--;
                        if (0 > nexttrackindex)
                        {
                            nexttrackindex = CurrentPlaylist.Tracks.Count - 1;
                        }
                        if (CurrentPlaylist.Tracks[nexttrackindex].TrackExists)
                        {
                            break;
                        }
                    }
                }
                _openedTrackWithStandardBackward = true;
                newtrack = CurrentPlaylist.Tracks[nexttrackindex];
            }

            CSCoreEngine.StopPlayback();
            if (await CSCoreEngine.OpenTrack(newtrack))
            {
                CSCoreEngine.TogglePlayPause();
            }
        }
Ejemplo n.º 9
0
 public NotificationService(CSCoreEngine cscore)
 {
     cscore.TrackChanged += cscore_TrackChanged;
 }
Ejemplo n.º 10
0
 public void Load()
 {
     SoundOutList     = CSCoreEngine.GetSoundOutList();
     SelectedSoundOut = SoundOutList.First(x => x.SoundOutMode == Config.SoundOutMode);
     CurrentLanguage  = Config.Languages.First(x => x.Code == Config.Language);
 }