示例#1
0
        private void PlaySelectedIndex(int i)
        {
            string filename  = _fullPaths[i].FullName;
            var    filename2 = _fullPaths[i].Name;
            var    converter = new NameConverter();
            var    shortname = converter.Convert(filename2, null, null, null);

            _player.Open(new Uri(filename, UriKind.Absolute));

            System.Threading.Thread.Sleep(500);
            var duration     = _player.NaturalDuration.TimeSpan;
            var testDuration = new TimeSpan(0, 0, 0);

            _player.Position = testDuration;

            _player.Play();
            IsPause = false;
            _timer.Start();
            Button1.Width  = 65;
            Button1.Height = 65;


            var Image2 = new BitmapImage(new Uri(@"Image/pause.png", UriKind.RelativeOrAbsolute));

            PlayIcon.Width  = 60;
            PlayIcon.Height = 60;
            PlayIcon.Source = Image2;
        }
示例#2
0
        private void timer_Tick(object sender, EventArgs e)
        {
            if (_player.Source != null)
            {
                if (_lastIndex < _fullPaths.Count)
                {
                    var filename  = _fullPaths[_lastIndex].Name;
                    var converter = new NameConverter();
                    var shortname = converter.Convert(filename, null, null, null);

                    var currentPos = _player.Position.ToString(@"mm\:ss");
                    var duration   = _player.NaturalDuration.TimeSpan.ToString(@"mm\:ss");

                    MusicPlaying.Text       = String.Format($"{currentPos} / {duration} --- {shortname}");
                    MusicPlaying.Foreground = Brushes.Yellow;
                }
            }
            else
            {
                Title = "No file selected...";
            }
        }