예제 #1
0
        /// <summary>
        /// Constructeur prenant en entree un fichier xml contenant les pistes stockes
        /// </summary>
        /// <param name="file"></param>
        public LocalPlaylist(string file)
        {
            LocalPlaylist playList = Read(file);

            Name         = playList.Name;
            Tracks       = playList.Tracks;
            CurrentIndex = 0;
        }
예제 #2
0
        private void OnClickCreatePlaylist(object sender, RoutedEventArgs e)
        {
            LocalPlaylist playlist = new LocalPlaylist()
            {
                Name = m_playListTextBox.Text
            };

            playlist.Save(System.IO.Path.Combine(PLAYLISTS_DIRECTORY, playlist.Name + ".xml"));
            Playlists.Add(playlist.Name);
        }
예제 #3
0
        /// <summary>
        /// permet de lire un  fichier xml contenant des pistes stockes
        /// </summary>
        /// <param name="file"></param>
        /// <returns>LocalPlaylist</returns>
        public static LocalPlaylist Read(string file)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(LocalPlaylist));
            LocalPlaylist playList   = new LocalPlaylist();

            using (StreamReader reader = new StreamReader(file))
            {
                playList = (LocalPlaylist)serializer.Deserialize(reader);
            }
            return(playList);
        }
예제 #4
0
        private void OnPlayPlaylist(object sender, RoutedEventArgs e)
        {
            Button    play      = sender as Button;
            TextBlock textBlock = VisualTreeHelper.GetChild(VisualTreeHelper.GetParent(play), 1) as TextBlock;
            string    name      = textBlock?.Text;

            if (name != null)
            {
                CurrentPlaylist = new LocalPlaylist(System.IO.Path.Combine(PLAYLISTS_DIRECTORY, name + ".xml"));
                PlayNextTrackInCurrentPlaylist();
            }
        }
예제 #5
0
 private void OnClickAddToPlaylist(object sender, RoutedEventArgs e)
 {
     if (CurrentTrack != null)
     {
         string        file     = System.IO.Path.Combine(PLAYLISTS_DIRECTORY, (string)m_playlistsComboBox.SelectedItem + ".xml");
         LocalPlaylist playlist = new LocalPlaylist(file);
         bool          added    = playlist.Add(CurrentTrack);
         playlist.Save(file);
         if (added)
         {
             MessageBox.Show("Track added");
         }
         else
         {
             MessageBox.Show("Track exists already");
         }
     }
 }