1 //Nothing 2 //Nothing 3 string[] files = Directory.GetFiles(Path.GetDirectoryName(App.config.MainConfigPath), "bgmusic_?.mp3"); 4 if (files.Count() != 0) 5 { 6 Random random = new Random(); 7 mediaElement.Source = new Uri(files[random.Next(files.Count())]); 8 this.volumeButton.Visibility = Visibility.Visible; 9 mediaElement.Play(); 10 mediaElement.Volume = 0; 11 await Task.Factory.StartNew(() => 12 { 13 try 14 { 15 for (int i = 0; i < 50; i++) 16 { 17 this.Dispatcher.Invoke(new Action(() => 18 { 19 this.mediaElement.Volume += 0.01; 20 })); 21 Thread.Sleep(50); 22 } 23 } 24 catch (Exception) { } 25 }); 26 27
C# WPF 解决方案MineRealms启动器 自动随机播放音乐的代码
猜你喜欢
转载自www.cnblogs.com/Dinnerbone/p/12039966.html
今日推荐
周排行