示例#1
0
 public MainWindow()
 {
     InitializeComponent();
     leftListBox.SelectionChanged += new SelectionChangedEventHandler(leftListBox_SelectionChanged);
     rightListBox.SelectionChanged += new SelectionChangedEventHandler(rightListBox_SelectionChanged);
     player = new MediaPlayer();
     timer = new DispatcherTimer();
     user = new User();
     timer.Interval = new TimeSpan(0, 0, 1);
     timer.Tick += new EventHandler(timer_Tick);
     player.MediaOpened += new EventHandler(player_MediaOpened);
     player.MediaEnded += new EventHandler(player_MediaEnded);
     player.MediaFailed += new EventHandler<ExceptionEventArgs>(player_MediaFailed);
     trackSlider.Tag = true;
 }
 public MainWindow()
 {
     InitializeComponent();
     Properties.Settings.Default.cachePath = Directory.GetCurrentDirectory() + "\\AudioCache";
     user = new User();
     AudioCache.GetAudio(rightListBox, user);
     leftListBox.SelectionChanged += new SelectionChangedEventHandler(leftListBox_SelectionChanged);
     rightListBox.SelectionChanged += new SelectionChangedEventHandler(rightListBox_SelectionChanged);
     player = new MediaPlayer();
     timer = new DispatcherTimer();
     timer.Interval = new TimeSpan(0, 0, 1);
     timer.Tick += new EventHandler(timer_Tick);
     player.MediaOpened += new EventHandler(player_MediaOpened);
     player.MediaEnded += new EventHandler(player_MediaEnded);
     player.MediaFailed += new EventHandler<ExceptionEventArgs>(player_MediaFailed);
     trackSlider.Tag = true;
 }
 public static void GetAudio(ListBox lb, User user)
 {
     string[] audios = Directory.GetFiles(Properties.Settings.Default.cachePath);
     int pathLength = Properties.Settings.Default.cachePath.Length;
     user.tracks = new List<Track>();
     foreach (var item in audios)
     {
         string songName = item.Substring(pathLength + 1, item.Length - pathLength - 5);
         string[] nameParts = songName.Split('-');
         lb.Items.Add(songName);
         user.tracks.Add(new Track()
             {
               artist = nameParts[0],
               title = nameParts[1]
             }
             );
     }
 }