public void DoubleClickItem(AyDragInfo dragInfo) { PlayListItemModel music = dragInfo.SourceItem as PlayListItemModel; SetPlayLock(); PlayAyMusic(music); }
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("音乐文件不存在!"); } }