예제 #1
0
        /// <summary>
        /// Call lyric provider to check lyric
        /// </summary>
        public void SetLyricSynchronously()
        {
            if (!LyricWindow.IsVisible)
            {
                return;
            }

            Task.Run(async() =>
            {
                if (_searchLyricTask?.IsTaskBusy() == true)
                {
                    await Task.WhenAny(_searchLyricTask);
                }

                _searchLyricTask = Task.Run(async() =>
                {
                    if (!_controller.IsPlayerReady)
                    {
                        return;
                    }

                    var lyricInst         = Service.Get <LyricsInst>();
                    var meta              = _controller.PlayList.CurrentInfo.OsuFile.Metadata;
                    MetaString metaArtist = meta.ArtistMeta;
                    MetaString metaTitle  = meta.TitleMeta;
                    var lyric             = await lyricInst.LyricProvider.GetLyricAsync(metaArtist.ToUnicodeString(),
                                                                                        metaTitle.ToUnicodeString(), (int)_controller.Player.Duration.TotalMilliseconds);
                    LyricWindow.SetNewLyric(lyric, metaArtist, metaTitle);
                    LyricWindow.StartWork();
                });
            });
        }
예제 #2
0
        /// <summary>
        /// Call lyric provider to check lyric
        /// </summary>
        public void SetLyricSynchronously()
        {
            if (!LyricWindow.IsVisible)
            {
                return;
            }

            Task.Run(async() =>
            {
                if (_searchLyricTask?.IsTaskBusy() == true)
                {
                    await Task.WhenAny(_searchLyricTask);
                }

                _searchLyricTask = Task.Run(async() =>
                {
                    var player = Services.Get <PlayersInst>().AudioPlayer;
                    if (player == null)
                    {
                        return;
                    }

                    var meta      = player.OsuFile.Metadata;
                    var lyricInst = Services.Get <LyricsInst>();
                    var lyric     = await lyricInst.LyricProvider.GetLyricAsync(meta.ArtistMeta.ToUnicodeString(),
                                                                                meta.TitleMeta.ToUnicodeString(), player.Duration);
                    LyricWindow.SetNewLyric(lyric, player.OsuFile);
                    LyricWindow.StartWork();
                });
            });
        }
예제 #3
0
        /// <summary>
        /// Call lyric provider to check lyric
        /// todo: this should run synchronously.
        /// </summary>
        public void SetLyricSynchronously()
        {
            if (!LyricWindow.IsVisible)
            {
                return;
            }
            if (InstanceManage.GetInstance <PlayersInst>().AudioPlayer == null)
            {
                return;
            }
            var lyric = InstanceManage.GetInstance <LyricsInst>().LyricProvider.GetLyric(InstanceManage.GetInstance <PlayersInst>().AudioPlayer.OsuFile.Metadata.ArtistMeta.ToUnicodeString(),
                                                                                         InstanceManage.GetInstance <PlayersInst>().AudioPlayer.OsuFile.Metadata.TitleMeta.ToUnicodeString(), InstanceManage.GetInstance <PlayersInst>().AudioPlayer.Duration);

            LyricWindow.SetNewLyric(lyric, InstanceManage.GetInstance <PlayersInst>().AudioPlayer.OsuFile);
            LyricWindow.StartWork();
        }