Exemplo n.º 1
0
 public static MusicLibrary GetInstance()
 {
     if (instance == null)
     {
         instance = new MusicLibrary();
     }
     return(instance);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Plays the audio file chosen by user
        /// </summary>
        /// <param name="tracks">the list containing the audio file (e. g. playlist or library)</param>
        public async void SetAudio(IAudio audio, ObservableList <IAudio> tracks)
        {
            imageInside.Source = new BitmapImage(new Uri("pack://application:,,,/Icons/Pause.png"));
            Player.MediaPlayer.SetMedia(new Uri(audio.FilePath));
            _tracks            = tracks;
            _currentAudio      = audio;
            TrackBar.IsEnabled = true;
            _currentAudio.GetData();
            Player.MediaPlayer.Play();
            SetFavsState();
            StartTimers();
            SettingMaximum();
            try
            {
                var TrackData = await audio.GetTrackTaskAsync();

                if (TrackData != null)
                {
                    geniusInfoAvailable   = true;
                    infoBoxArtist.Text    = TrackData.Artist.Name;
                    infoBoxTrackName.Text = TrackData.Title;
                    Thumbnail.Source      = await _currentAudio.GetImageTaskAsync(TrackData.AlbumCoverThumbnailUrl);

                    MainPage.GetInstance().Update(_currentAudio);
                }
                else
                {
                    geniusInfoAvailable = false;
                    if (_tracks == Library.Files)
                    {
                        MainFrame.Content = MusicLibrary.GetInstance();
                    }
                    else
                    {
                        MainFrame.Content = PlaylistPage.GetInstance();
                    }

                    infoBoxArtist.Text    = _currentAudio.Artist;
                    infoBoxTrackName.Text = _currentAudio.Track;
                    Thumbnail.Source      = new BitmapImage(new Uri("pack://application:,,,/Icons/music-record-small.png"));
                }
            }
            catch (Exception) {
                return;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Plays previous track in the list
 /// </summary>
 private void Previous_Click(object sender, RoutedEventArgs e)
 {
     if (_tracks != null)
     {
         IAudio audio = _tracks.GetPrev(_currentAudio);
         if (audio != null)
         {
             int index = _tracks.GetIndex(audio);
             if (_tracks == Library.Files)
             {
                 MusicLibrary.GetInstance().SetSelection(index);
             }
             else
             {
                 PlaylistPage.GetInstance().SetSelection(index);
             }
             SetAudio(audio, _tracks);
         }
     }
 }
Exemplo n.º 4
0
        private void Button_ClickToLibrary(object sender, RoutedEventArgs e)
        {
            // no library path chosen
            if (string.IsNullOrWhiteSpace(SystemState.Instance.LibraryPath))
            {
                using (var fbd = new FolderBrowserDialog())
                {
                    fbd.ShowDialog();

                    // user has chosen the library
                    if (!string.IsNullOrWhiteSpace(fbd.SelectedPath))
                    {
                        Library.Update(fbd.SelectedPath);
                        MainFrame.Content = MusicLibrary.GetInstance();
                    }
                }
            }
            else
            {
                MainFrame.Content = MusicLibrary.GetInstance();
            }
        }