Пример #1
0
        public void Play(Mp3File mp3File)
        {
            _currentPlaying        = mp3File;
            AlbumCoverImage.Source = mp3File.AlbumCover != null ? _currentPlaying.AlbumCover : _defaultArtwork;
            _player.URL            = mp3File.FilePath;
            TitleTextBox.Text      = _currentPlaying.FullTitle;
            var timeSpan = TimeSpan.FromSeconds(_currentPlaying.MaxPosition);

            MaxPositionTextBlock.Text = String.Format("{0}:{1:00}", timeSpan.Minutes, timeSpan.Seconds);
        }
Пример #2
0
        private void OpenDirectory_OnClick(object sender, RoutedEventArgs e)
        {
            CommonOpenFileDialog dialog = new CommonOpenFileDialog();

            dialog.InitialDirectory = "C:\\Users";
            dialog.IsFolderPicker   = true;
            if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                var     files    = Directory.GetFiles(dialog.FileName, "*.mp3");
                Mp3File firstMp3 = new Mp3File(files[0]);
                Mp3Files.Add(firstMp3);
                for (int i = 1; i < files.Length; i++)
                {
                    Mp3Files.Add(new Mp3File(files[i]));
                }
                Play(firstMp3);
            }
        }
Пример #3
0
        private void OpenButton_OnClick(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                Multiselect = true,
                Filter      = "mp3 files (*.mp3)|*.mp3"
            };

            openFileDialog.ShowDialog();


            if (openFileDialog.FileNames.Length > 0)
            {
                Mp3File firstMp3 = new Mp3File(openFileDialog.FileNames[0]);
                Mp3Files.Add(firstMp3);
                for (int i = 1; i < openFileDialog.FileNames.Length; i++)
                {
                    Mp3Files.Add(new Mp3File(openFileDialog.FileNames[i]));
                }
                Play(firstMp3);
            }
        }
Пример #4
0
        private void ListViewItemHandleDoubleClick(object sender, RoutedEventArgs e)
        {
            Mp3File mp3File = (Mp3File)((ListViewItem)sender).Content;

            Play(mp3File);
        }