Ejemplo n.º 1
0
        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;
                }
            });
        }
Ejemplo n.º 2
0
        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");
                }
            };
        }