private void PlayButtonClick(object sender, RoutedEventArgs e) { controller.Pause(); TimeSpan oldtime = controller.Position; controller.Duration = null; controller.Resume(); controller.Position = oldtime; LrcUpdateTimer.Start(); UpdateLrcEditBarAutoScroll(true); }
private void LoadLrc(Lrc lrcdata) { LrcData = lrcdata; lrcdatapanel.Children.Clear(); LrcTimeLines.Clear(); foreach (var item in lrcdata.LrcWord) { var textblock = new TextBlock(); textblock.Style = (Style)Resources["unlrcview"]; textblock.Text = item.Value; LrcTimeLines.Add(TimeSpan.FromMilliseconds(item.Key)); lrcdatapanel.Children.Add(textblock); } if (Class.MediaControl.GetCurrent().CurrentState == Windows.Media.Playback.MediaPlayerState.Playing) { LrcUpdateTimer.Start(); } }
private void LrcViewPanel_CurrentStateChanged(MediaPlayer sender, object args) { mainFrame.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { switch (sender.CurrentState) { case MediaPlayerState.Playing: LoadLrcFromLocal(); LrcUpdateTimer.Start(); break; case MediaPlayerState.Paused: LoadLrcFromLocal(); LrcUpdateTimer.Stop(); break; default: break; } }); }
private void InitializeWordLyricAdapter() { lyricAdapter = new WordLyric.WordLyricAdapter(); lyricAdapter.OnAddLyricLine += (line) => { LyricShowControl.LoadLyric(line, false); LyricTranslateShowControl.LoadLyric(line, true); }; lyricAdapter.OnActiveLyricLine += (info) => { LyricShowControl.SetLyricLine(info.LineNumber, info.GroupActiveInfo); LyricTranslateShowControl.SetLyricLine(info.LineNumber, info.TranslateActiveInfo); StyleTextBox.Text = info.LyricLine.Style; }; lyricAdapter.OnActiveGroup += (info) => { //LogPrint($"Active group {info.GroupId} in line {info.LineNumber}"); if (!info.IsTranslate) { LyricShowControl.ActiveGroup(info.LineNumber, info.GroupId); } else { LyricTranslateShowControl.ActiveGroup(info.LineNumber, info.GroupId); } }; LrcUpdateTimer.Tick += (s, e) => { if (player?.PlaybackSession?.PlaybackState == MediaPlaybackState.Playing) { //LogPrint($"media seek to {player.Time / 1000f}"); UpdateLyricProgress(); } else { LrcUpdateTimer.Stop(); LogPrint("media player State:" + (player?.PlaybackSession?.PlaybackState)?.ToString() ?? "NO PLAYER"); } }; }