private void SkinGetterXuanChuan_Loaded(object sender, RoutedEventArgs e) { //double _1 = 0; for (int i = 0; i < Number; i++) { RadioButton rb = new RadioButton(); rb.AddHandler(UIElement.MouseEnterEvent, new MouseEventHandler(Rb_MouseEnter), true); rb.AddHandler(UIElement.MouseLeaveEvent, new MouseEventHandler(Rb_MouseLeave), true); rb.Checked += Rb_Checked; rb.SetResourceReference(RadioButton.StyleProperty, "rdoNavSkin"); if (i == 0) { rb.IsChecked = true; } if (i > 0) { rb.Margin = new Thickness(12, 0, 0, 0); } rb.Tag = i; //_1 = _1 + LeftWidth; sp_navs.Children.Add(rb); } ad = new AyAniDouble(prev); isfirst = true; autoPlay = AyTime.setInterval(1000, () => { if (currplayIndex == (Number - 1)) { //最后1个 currplayIndex = 0; var _1 = sp_navs.Children[currplayIndex.ToInt()]; var _2 = _1 as RadioButton; _2.IsChecked = true; } else { currplayIndex++; var _1 = sp_navs.Children[currplayIndex.ToInt()]; var _2 = _1 as RadioButton; _2.IsChecked = true; } }); }
internal static void PlayAyMusic(PlayListItemModel music) { if (System.IO.File.Exists(music.SongPath)) { if (currentPlayTimer != null) { currentPlayTimer.Stop(); currentPlayTimer = null; } MainWindow.curr.ProgressEnbaled = true; if (lastMusic != null) { MainWindow.CurrentPlayer.Stop(); MainWindow.CurrentPlayer.Dispose(); } if (music.ExtName == ".mp3") { Mp3File mp3 = new Mp3File(music.SongPath); if (mp3.TagHandler.Picture != null) { MemoryStream stream = new MemoryStream(AyFuncFactory.GetFunc <AyFuncBitmapWithWpf>().ImageToBytes(mp3.TagHandler.Picture, System.Drawing.Imaging.ImageFormat.Jpeg)); string filename = AyFuncFactory.GetFunc <AyFuncSecrity>().GetMD5Result(mp3.TagHandler.Song + mp3.TagHandler.Artist.ToObjectString()); filename = ExtendUtils.GetDATA_TEMP_ALBUM_PATH() + "\\" + filename + ".jpg"; var dsd = imageSourceConverter.ConvertFrom(stream); if (!File.Exists(filename)) { System.Drawing.Image bm = System.Drawing.Image.FromStream(stream, true); bm.Save(filename); } if (dsd == null) { MainWindow.SetAlbumImage(null, filename); } else { MainWindow.SetAlbumImage(dsd as System.Windows.Media.Imaging.BitmapFrame, filename); } } else { MainWindow.SetAlbumImage(null); } MainWindow.curr.Singer = "- " + mp3.TagHandler.Artist; mp3 = null; AyExtension.MemoryGC(); } else { MainWindow.curr.Singer = "- 未知AY"; } MainWindow.CurrentPlayer = new VlcPlayer(); MainWindow.CurrentPlayer.Initialize(@"Contents\LibVlc", new string[] { "-I", "--dummy", "--ignore-config", "--no-video-title", "--no-sub-autodetect-file" }); MainWindow.CurrentPlayer.EndBehavior = EndBehavior.Repeat; MainWindow.CurrentPlayer.LoadMedia(music.SongPath); MainWindow.CurrentPlayer.Play(); MainWindow.CurSongGuid = music.SongGuid; music.PlayStatus = true; MainWindow.curr.WorldPlayStatus = true; MainWindow.curr.GeName = music.SongNameWithoutExt; if (lastMusic != null && lastMusic.SongGuid != music.SongGuid) { lastMusic.PlayStatus = false; } lastMusic = music; MainWindow.curr.WorldLoveStatus = music.LoveStatus; currentPlayTimer = AyTime.setInterval(100, () => { var totalDuration = MainWindow.CurrentPlayer.GetDuration(); if (totalDuration.Hours > 0) { MainWindow.curr.TotalTime = string.Format("{0:00}:{1:00}:{2:00}", totalDuration.Hours, totalDuration.Minutes, totalDuration.Seconds); } else if (totalDuration.Hours == 0) { MainWindow.curr.TotalTime = string.Format("{0:00}:{1:00}", totalDuration.Minutes, totalDuration.Seconds); } if (MainWindow.CurrentPlayer != null && (MainWindow.CurrentPlayer.State == Meta.Vlc.Interop.Media.MediaState.Paused || MainWindow.CurrentPlayer.State == Meta.Vlc.Interop.Media.MediaState.Stopped)) { currentPlayTimer.Stop(); } var dd = MainWindow.CurrentPlayer.GetPlayTime(); MainWindow.curr.CurrentTime = string.Format("{0:00}:{1:00}:{2:00}", dd.Hours, dd.Minutes, dd.Seconds); if (dd.Hours > 0) { MainWindow.curr.CurrentTime = string.Format("{0:00}:{1:00}:{2:00}", dd.Hours, dd.Minutes, dd.Seconds); } else if (dd.Hours == 0) { MainWindow.curr.CurrentTime = string.Format("{0:00}:{1:00}", dd.Minutes, dd.Seconds); } if (!MainWindow.curr.sliderProgressLock) { MainWindow.curr.CurrentPlayerPosition = MainWindow.CurrentPlayer.Position; } }); } else { AyMessageBox.ShowInformation("音乐文件不存在!"); } }
public static void Start(Action func) { isContinue = true; timer = AyTime.setInterval(10, func); }