Пример #1
0
 private void ListView_Selected(object sender, SelectionChangedEventArgs e)
 {
     if (e.AddedItems.Count > 0)
     {
         song newSong = e.AddedItems[0] as song;
         currentSong = newSong;
         player.stop();
         player_changeState();
         song_change();
     }
 }
Пример #2
0
        private void PlayThisSong(object sender, MouseButtonEventArgs e)
        {
            song Song = (song)((ListViewItem)sender).DataContext;

            player.stop();
            currentSong          = Song;
            currentSong.Selected = true;
            player.play(Song);
            player_changeState();
            song_change();
        }
Пример #3
0
 private void InsertPlaylist(object sender, RoutedEventArgs e)
 {
     if (PlaylistComboBox.SelectedValue != null)
     {
         player.stop();
         currentSong = null;
         player_changeState();
         song_change();
         playlist Playlist = PlaylistComboBox.SelectedValue as playlist;
         playlist.Clear();
         playlist.AddRange(Playlist.Songs);
         NotifyPropertyChanged("Playlist");
     }
 }
Пример #4
0
 private void PlayPrev(object sender, RoutedEventArgs e)
 {
     if (currentSong != null && playlist != null && playlist.Count > 0)
     {
         song Song = getPrevSong();
         if (Song == null)
         {
             return;
         }
         currentSong          = Song;
         currentSong.Selected = true;
         song_change();
         player.stop();
         System.Threading.Thread.Sleep(200);
         player.play(currentSong);
         song_change();
         player_changeState();
     }
 }
Пример #5
0
 public void play(song Song)
 {
     if (Song == null)
     {
         return;
     }
     Song.startDownloading();
     if (playbackState == StreamingPlaybackState.Stopped || playbackState == StreamingPlaybackState.Finished)
     {
         playbackState        = StreamingPlaybackState.Buffering;
         bufferedWaveProvider = null;
         ThreadPool.QueueUserWorkItem(StreamMp3, Song.Uri.AbsoluteUri);
         timer1.Enabled = true;
     }
     else if (playbackState == StreamingPlaybackState.Paused)
     {
         playbackState = StreamingPlaybackState.Buffering;
     }
 }
Пример #6
0
 void parseList(string list, BackgroundWorker worker)
 {
     worker.WorkerReportsProgress = true;
     worker.ReportProgress(20);
     if (list != null && !string.IsNullOrWhiteSpace(list))
     {
         artists = new ObservableCollection <artist>();
         string[] temp = null;
         temp = list.Split('\n');
         List <string> SongList  = new List <string>(temp);
         int           SongCount = SongList.Count;
         if (SongCount > 0)
         {
             int i = 0;
             foreach (string title in SongList)
             {
                 temp = new string[] { "::" };
                 string[] splitLine = title.Split(temp, StringSplitOptions.None);
                 i++;
                 worker.ReportProgress((i / SongCount) * 100);
                 if (splitLine.Length != 7)
                 {
                     continue;
                 }
                 var    temp1         = artists.Where(x => x.Name == splitLine[1]);
                 artist currentArtist = null;
                 // artist handling
                 if (temp1 != null && temp1.Count() > 0)
                 {
                     // artist exits
                     currentArtist = temp1.First();
                 }
                 else
                 {
                     // artirst not exits
                     currentArtist = new artist(splitLine[1]);
                     artists.Add(currentArtist);
                 }
                 // album handling
                 var   temp2        = currentArtist.Albums.Where(x => x.Name == splitLine[2]);
                 album currentAlbum = null;
                 if (temp2 != null && temp2.Count() > 0)
                 {
                     // album exits
                     currentAlbum = temp2.First();
                 }
                 else
                 {
                     // album not exits
                     currentAlbum = new album(splitLine[2]);
                     Albums.Add(currentAlbum);
                     currentArtist.Albums.Add(currentAlbum);
                 }
                 // song handling
                 var  temp3       = currentAlbum.Songs.Where(x => x.Name == splitLine[3]);
                 song currentSong = null;
                 if (temp3 != null && temp3.Count() > 0)
                 {
                     // song exits
                     currentSong = temp3.First();
                 }
                 else
                 {
                     // song not exits
                     int sec = -1;
                     int.TryParse(splitLine[6], out sec);
                     currentSong = new song(splitLine[4], splitLine[5], splitLine[0], sec);
                     currentAlbum.Songs.Add(currentSong);
                     Songs.Add(currentSong.UID, currentSong);
                 }
             }
         }
         NotifyPropertyChanged("Artists");
     }
 }