public MainPage() { this.InitializeComponent(); currentCD = new CDMetadata(); if (ListDevices.Items != null) { ListDevices.Items.Clear(); } ListDeviceInformation = new List <CDReaderDevice>(); ListDevices.SelectionChanged += ListDevices_SelectionChanged; ButtonEjectMedia.IsEnabled = false; ButtonReadTable.IsEnabled = false; ButtonPlayTrack.IsEnabled = false; ButtonExtractTrack.IsEnabled = false; ButtonPlayWavFile.IsEnabled = false; ButtonStopPlayer.IsEnabled = false; ButtonStartDiscover.Visibility = Visibility.Visible; ButtonStopDiscover.Visibility = Visibility.Collapsed; ListDevices.IsEnabled = false; CheckListDevices(); FillComboTrack(); bAutoStart = false; // Bind player to element mediaPlayer = new Windows.Media.Playback.MediaPlayer(); mediaPlayerElement.SetMediaPlayer(mediaPlayer); mediaPlayer.MediaEnded += MediaPlayer_MediaEnded; mediaPlayer.MediaFailed += MediaPlayer_MediaFailed; mediaPlayer.MediaOpened += MediaPlayer_MediaOpened; mediaPlayer.PlaybackSession.PlaybackStateChanged += PlaybackSession_PlaybackStateChanged; }
private async void ButtonReadCDMetadata_Click(object sender, RoutedEventArgs e) { string id = ListDevices.SelectedItem as string; if (!string.IsNullOrEmpty(id) && (id != "None")) { CDReaderDevice device = null; if (ListDeviceInformation != null) { foreach (var d in ListDeviceInformation) { if (d.Id == id) { device = d; } } } if (device != null) { try { LogMessage("Device Name: " + device.Name); currentCD = await cdReaderManager.ReadMediaMetadata(device.Id); if ((currentCD != null) && (currentCD.Tracks.Count > 1)) { FillComboTrack(); LogMessage("Get CD Table Map successfull: " + currentCD.Tracks.Count.ToString() + " tracks"); FillComboTrack(); } } catch (UnauthorizedAccessException ex) { LogMessage("Exception while reading Table: " + ex.Message); } catch (Exception ex) { LogMessage("Exception while reading Table: " + ex.Message); } } } }