Beispiel #1
0
        public async Task Lookup(LyricsProvider provider, PlaylistItem playlistItem)
        {
            Logger.Write(this, LogLevel.Debug, "Looking up lyrics for file \"{0}\"..", playlistItem.FileName);
            var result = await provider.Lookup(playlistItem).ConfigureAwait(false);

            if (!result.Success)
            {
                Logger.Write(this, LogLevel.Warn, "Failed to look up lyrics for file \"{0}\".", playlistItem.FileName);
                return;
            }
            Logger.Write(this, LogLevel.Debug, "Looking up lyrics for file \"{0}\": OK, updating meta data.", playlistItem.FileName);
            lock (playlistItem.MetaDatas)
            {
                var metaDataItem = playlistItem.MetaDatas.FirstOrDefault(
                    element => string.Equals(element.Name, CommonMetaData.Lyrics, StringComparison.OrdinalIgnoreCase)
                    );
                if (metaDataItem == null)
                {
                    metaDataItem = new MetaDataItem(CommonMetaData.Lyrics, MetaDataItemType.Tag);
                    lock (playlistItem.MetaDatas)
                    {
                        playlistItem.MetaDatas.Add(metaDataItem);
                    }
                }
                metaDataItem.Value = result.Lyrics;
            }
            await this.MetaDataManager.Save(
                new[] { playlistItem },
                true,
                false,
                CommonMetaData.Lyrics
                ).ConfigureAwait(false);
        }
Beispiel #2
0
        public Task Lookup(LyricsProvider provider)
        {
            var outputStream = this.PlaybackManager.CurrentStream;

            if (outputStream == null)
            {
#if NET40
                return(TaskEx.FromResult(false));
#else
                return(Task.CompletedTask);
#endif
            }
            var playlistItem = outputStream.PlaylistItem;
            return(this.Lookup(provider, playlistItem));
        }
Beispiel #3
0
        public Task Lookup(LyricsProvider provider)
        {
            var outputStream = this.PlaybackManager.CurrentStream;

            if (outputStream == null)
            {
#if NET40
                return(TaskEx.FromResult(false));
#else
                return(Task.CompletedTask);
#endif
            }
            var playlistItem = outputStream.PlaylistItem;
            return(this.OnDemandMetaDataProvider.GetMetaData(
                       new[] { outputStream.PlaylistItem },
                       new OnDemandMetaDataRequest(
                           CommonMetaData.Lyrics,
                           MetaDataItemType.Tag,
                           true,
                           provider
                           )
                       ));
        }
Beispiel #4
0
 public void Register(LyricsProvider provider)
 {
     this.Providers.Add(provider);
 }