/// <summary> /// 鼠标拖动歌词 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CanvasLyric_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) { if (IsStartDragLyric == true) { LyricPointB.X = e.GetPosition(this).X; LyricPointB.Y = e.GetPosition(this).Y; if (LyricPointB.Y != LyricPointA.Y) { if (LyricPointB.Y - LyricPointA.Y > 0) { //向下(每次变化0.12秒,该值可以按需调整.) DragAfterLyricTime -= 0.12; } if (LyricPointB.Y - LyricPointA.Y < 0) { //向上 DragAfterLyricTime += 0.12; } tbDragTime.Text = string.Format("{0}:{1}", (int)DragAfterLyricTime / 60, (DragAfterLyricTime % 60).ToString("F2")); LyricShow.refrshLyricShowWhenSkipPlay(DragAfterLyricTime); LyricPointA.Y = LyricPointB.Y; } else { // 没上没下 } } }
/// <summary> /// 鼠标按下准备拖动歌词 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CanvasLyric_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { try { System.Windows.Input.Cursor csB = new System.Windows.Input.Cursor(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\cursor\\hand-close.cur"); this.Cursor = csB; } catch { } LyricShow.pauseOrContinueLyricShow(true);//暂停歌词秀,然后拖动 DragBeforeLyricTime = player.Position.TotalSeconds; DragAfterLyricTime = DragBeforeLyricTime; IsStartDragLyric = true; LyricPointA.X = e.GetPosition(this).X; LyricPointA.Y = e.GetPosition(this).Y; LyricPointB.X = e.GetPosition(this).X; LyricPointB.Y = e.GetPosition(this).Y; BaseLine.Visibility = Visibility.Visible; tbDragTime.Visibility = Visibility.Visible; try { tbDragTime.Text = string.Format("{0}:{1}", player.Position.Minutes, player.Position.Seconds); } catch { IsStartDragLyric = false; tbDragTime.Text = "0:00.00"; } }
private void jd_MouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { LyricShow.refreshLyricShow(player.Position.TotalSeconds); player.Stop(); SetPosition(TimeSpan.FromMilliseconds(jd.Value)); player.Play(); } }
private void Tick(object sender, EventArgs e) { try { LyricShow.refreshLyricShow(player.Position.TotalSeconds); jd.Maximum = GetMusicDurationTime().TotalMilliseconds; jd.Value = GetPosition().TotalMilliseconds; } catch { } }
/// <summary> /// 鼠标离开歌词面板 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CanvasLyric_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e) { this.Cursor = System.Windows.Input.Cursors.Arrow; BaseLine.Visibility = Visibility.Collapsed; tbDragTime.Visibility = Visibility.Collapsed; if (IsStartDragLyric == true) { IsStartDragLyric = false; player.Position = TimeSpan.FromSeconds(DragAfterLyricTime); LyricShow.refrshLyricShowWhenSkipPlay(DragAfterLyricTime); // TBTime.Text = string.Format("0:{0}:{1}", player.Position.Minutes, player.Position.Seconds); } }
public MusicControl() { InitializeComponent(); player.MediaEnded += io; t.Interval = 500; t.Tick += Tick; if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + $@"MusicCache") == false) { Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + $@"MusicCache"); } if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + $@"MusicDownload") == false) { Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + $@"MusicDownload"); } getLT = new GetLyricAndLyricTime(); lyricShow = new LyricShow(CanvasLyric, StackPanelCommonLyric, CanvasFocusLyric, TBFocusLyricBack, CanvasFocusLyricFore, TBFocusLyricFore); }
private void BtnOpenLyric_Click(object sender, System.Windows.RoutedEventArgs e) { OpenFileDialog _openfile = new OpenFileDialog() { Title = "打开歌词文件", Filter = "歌词文件(*.lrc)|*.lrc", RestoreDirectory = true }; if (_openfile.ShowDialog(this) == true) { getLT.getLyricAndLyricTimeByLyricPath(_openfile.FileName); LyricShow.initializeLyricUI(getLT.LyricAndTimeDictionary);//解析歌词->得到歌词时间和歌词 LyricShow.setCommonLyricFontFamily(new System.Windows.Media.FontFamily("微软雅黑")); LyricShow.setCommonLyricFontSize(16); _lyrictimer.Start(); } }
private void Window_Loaded(object sender, System.Windows.RoutedEventArgs e) { System.IntPtr hwnd = new System.Windows.Interop.WindowInteropHelper(this).Handle; BassNet.Registration("*****@*****.**", "2X3931422312422"); if (Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, hwnd)) { _myStreamCreate = new STREAMPROC(MyFileProc); _myStreamCreateUser = new BASS_FILEPROCS( new FILECLOSEPROC(MyFileProcUserClose), new FILELENPROC(MyFileProcUserLength), new FILEREADPROC(MyFileProcUserRead), new FILESEEKPROC(MyFileProcUserSeek)); MainVolume.Value = Bass.BASS_GetVolume() * 100; if (Bass.BASS_GetVolume() >= 80) { packicon_volumestate.Kind = MaterialDesignThemes.Wpf.PackIconKind.VolumeHigh; } _maintimer = new System.Windows.Threading.DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(500) }; _maintimer.Tick += new EventHandler(update_elapsedtime); _lyrictimer = new System.Windows.Threading.DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(500) }; _lyrictimer.Tick += new EventHandler(_lyrictimer_Tick); lyricShow = new LyricShow(CanvasLyric, StackPanelCommonLyric, CanvasFocusLyric, TBFocusLyricBack, CanvasFocusLyricFore, TBFocusLyricFore); getLT = new GetLyricAndLyricTime(); } else { System.Windows.MessageBox.Show(this, "Bass_Init error!"); } }
/// <summary> /// 鼠标释放,结束拖动歌词 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CanvasLyric_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { try { System.Windows.Input.Cursor csC = new System.Windows.Input.Cursor(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\cursor\\hand-open.cur"); this.Cursor = csC; } catch { } BaseLine.Visibility = Visibility.Collapsed; tbDragTime.Visibility = Visibility.Collapsed; if (IsStartDragLyric == true) { IsStartDragLyric = false; if (isR == true) { LyricShow.IsPauseLyricShow = false; if (DragAfterLyricTime == DragBeforeLyricTime) { //有按下拖动歌词的意愿,但实际是没有拖动歌词,那么直接刷新不跳播 LyricShow.refrshLyricShowWhenSkipPlay(player.Position.TotalSeconds); } else { //刷新,并跳播 LyricShow.refrshLyricShowWhenSkipPlay(DragAfterLyricTime); player.Position = TimeSpan.FromSeconds(DragAfterLyricTime); player.Play(); } } else { LyricShow.IsPauseLyricShow = true; player.Position = TimeSpan.FromSeconds(DragAfterLyricTime); LyricShow.refrshLyricShowWhenSkipPlay(DragAfterLyricTime); // TBTime.Text = string.Format("0:{0}:{1}", player.Position.Minutes, player.Position.Seconds); } } }
private void _lyrictimer_Tick(object sender, EventArgs e) { LyricShow.refreshLyricShow(Bass.BASS_ChannelBytes2Seconds(_stream, Bass.BASS_ChannelGetPosition(_stream))); }
private async void io(object sender, EventArgs e) { // try { s.Data = Geometry.Parse("M2.432,11.997L13.69,1.714c0.393-0.392,0.393-1.028,0-1.42c-0.393-0.392-1.031-0.392-1.424,0L0.286,11.236c-0.21,0.209-0.299,0.487-0.285,0.76c-0.014,0.274,0.075,0.551,0.285,0.76l11.98,10.942c0.393,0.392,1.031,0.392,1.424,0c0.393-0.392,0.393-1.028,0-1.42L2.432,11.997z"); string i = ""; if (listBox.SelectedIndex != listBox.Items.Count) { i = (listBox.Items[listBox.SelectedIndex + 1] as MusicItemControl).Content; listBox.SelectedItem = listBox.Items[listBox.SelectedIndex + 1]; } else { i = (listBox.Items[0] as MusicItemControl).Content; listBox.SelectedItem = listBox.Items[0]; } isR = true; textBlock1.Text = i; lrcname.Text = ((listBox.SelectedItem as MusicItemControl).Music as string[])[1]; zk.Text = ((listBox.SelectedItem as MusicItemControl).Music as string[])[3]; img = ((listBox.SelectedItem as MusicItemControl).Music as string[])[22]; He.on = $"https://y.gtimg.cn/music/photo_new/T002R300x300M000{img}.jpg"; tx.Background = new ImageBrush(new BitmapImage(new Uri(He.on))); musicid = ((listBox.SelectedItem as MusicItemControl).Music as string[])[20]; // if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + $@"MusicCache/{i}.mp3")) //{ // musicurl = $"http://cc.stream.qqmusic.qq.com/C100{musicid}.m4a?fromtag=52"; string guid = "20D919A4D7700FBC424740E8CED80C6F"; string ioo = Uuuhh.GetWeb($"http://59.37.96.220/base/fcgi-bin/fcg_musicexpress2.fcg?version=12&miniversion=92&key=19914AA57A96A9135541562F16DAD6B885AC8B8B5420AC567A0561D04540172E&guid={guid}"); string vkey = He.Text(ioo, "key=\"", "\" speedrpttype", 0); musicurl = $"http://182.247.250.19/streamoc.music.tc.qq.com/M500{musicid}.mp3?vkey={vkey}&guid={guid}"; player.Open(new Uri(musicurl)); player.Play(); t.Start(); //WebClient dc = new WebClient() //{ // Proxy = He.proxy //}; //dc.DownloadFileCompleted += Fis; //dc.DownloadFileAsync(new Uri(musicurl), AppDomain.CurrentDomain.BaseDirectory + $@"MusicCache/{i}.mp3"); /////等待播放 //loading.Visibility = Visibility.Visible; // } // else // { // player.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + $@"MusicCache/{i}.mp3")); // player.Play(); //t.Start(); // } if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + $@"MusicCache/{textBlock1.Text}.lrc")) { string lrc = ((listBox.SelectedItem as MusicItemControl).Music as string[])[0]; string lrcid = lrc.Substring(lrc.Length - 2, 2); // MessageBox.Show(He.Text(sr.ReadToEnd(), @"<lyric><![CDATA[", "]]></lyric>", 0)); FileStream fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + $@"MusicCache/{i}.lrc", FileMode.Create); StreamWriter sw = new StreamWriter(fs); string ijo = He.Text(await Uuuhh.GetWebUAsync($"http://music.qq.com/miniportal/static/lyric/{lrcid}/{lrc}.xml"), @"<lyric><![CDATA[", "]]></lyric>", 0).Replace("'", "'"); if (ijo != "") { await sw.WriteAsync(ijo); await sw.FlushAsync(); sw.Close(); fs.Close(); if (LyricShow.IsOpenDeskLyric == false) { deskLyricWin = new DeskLyricWin(); deskLyricWin.Show(); LyricShow.openDeskLyric(deskLyricWin.textBlockDeskLyricFore, deskLyricWin.textBlockDeskLyricBack, deskLyricWin.canvasDeskLyricFore); LyricShow.HB = 204; LyricShow.HG = 122; LyricShow.HR = 0; LyricShow.CB = 193; LyricShow.CG = 180; LyricShow.CR = 180; } LyricShow.IsPauseLyricShow = false; getLT.getLyricAndLyricTimeByLyricPath(AppDomain.CurrentDomain.BaseDirectory + $@"MusicCache/{i}.lrc"); LyricShow.initializeLyricUI(getLT.LyricAndTimeDictionary);//解析歌词->得到歌词时间和歌词 } else { deskLyricWin.Close(); LyricShow.backInitial(); LyricShow.initializeLyricUI(null); LyricShow.IsPauseLyricShow = true; } } else { if (LyricShow.IsOpenDeskLyric == false) { deskLyricWin = new DeskLyricWin(); deskLyricWin.Show(); LyricShow.openDeskLyric(deskLyricWin.textBlockDeskLyricFore, deskLyricWin.textBlockDeskLyricBack, deskLyricWin.canvasDeskLyricFore); LyricShow.HB = 204; LyricShow.HG = 122; LyricShow.HR = 0; LyricShow.CB = 193; LyricShow.CG = 180; LyricShow.CR = 180; } LyricShow.IsPauseLyricShow = false; getLT.getLyricAndLyricTimeByLyricPath(AppDomain.CurrentDomain.BaseDirectory + $@"MusicCache/{textBlock1.Text}.lrc"); LyricShow.initializeLyricUI(getLT.LyricAndTimeDictionary);//解析歌词->得到歌词时间和歌词 } } // } // catch { deskLyricWin.Close(); LyricShow.backInitial(); LyricShow.initializeLyricUI(null); LyricShow.IsPauseLyricShow = true; } }