mirror of
https://github.com/jayfunc/BetterLyrics.git
synced 2026-01-12 19:24:55 +08:00
chores:
- Support reading local album art file passed by LX Music server - Support listening LX Music portable version - Fix translation not be read in search window
This commit is contained in:
@@ -315,15 +315,27 @@ namespace BetterLyrics.WinUI3.Helper
|
||||
// data URL,直接解析
|
||||
return DataUrlToByteArray(url);
|
||||
}
|
||||
else if (Uri.TryCreate(url, UriKind.Absolute, out var uri) &&
|
||||
(uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps))
|
||||
else if (Uri.TryCreate(url, UriKind.Absolute, out var uri))
|
||||
{
|
||||
// 普通网络图片,下载
|
||||
return await DownloadImageAsByteArrayAsync(url);
|
||||
if (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)
|
||||
{
|
||||
// 普通网络图片,下载
|
||||
return await DownloadImageAsByteArrayAsync(url);
|
||||
}
|
||||
else if (uri.Scheme == Uri.UriSchemeFile)
|
||||
{
|
||||
// 本地文件,读取
|
||||
var file = await StorageFile.GetFileFromPathAsync(uri.LocalPath);
|
||||
var buffer = await FileIO.ReadBufferAsync(file);
|
||||
return buffer.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 其他类型暂不支持
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
|
||||
return _settingsService.AppSettings.MediaSourceProvidersInfo.FirstOrDefault(s => s.Provider == id)?.IsEnabled ?? true;
|
||||
}
|
||||
|
||||
private bool IsMediaSourceTimelineSyncEnabled(string id)
|
||||
private bool IsMediaSourceTimelineSyncEnabled(string? id)
|
||||
{
|
||||
return _settingsService.AppSettings.MediaSourceProvidersInfo.FirstOrDefault(s => s.Provider == id)?.IsTimelineSyncEnabled ?? true;
|
||||
}
|
||||
@@ -519,7 +519,7 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
|
||||
{
|
||||
_dispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, async () =>
|
||||
{
|
||||
if (_cachedSongInfo?.PlayerId == Constants.PlayerID.LXMusic)
|
||||
if (PlayerIdMatcher.IsLXMusic(_cachedSongInfo?.PlayerId))
|
||||
{
|
||||
var data = JsonSerializer.Deserialize(e.Message, Serialization.SourceGenerationContext.Default.JsonElement);
|
||||
if (data.ValueKind == JsonValueKind.Number)
|
||||
@@ -533,7 +533,7 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
|
||||
_lxMusicDurationSeconds = data.GetDouble();
|
||||
}
|
||||
|
||||
if (IsMediaSourceTimelineSyncEnabled(Constants.PlayerID.LXMusic))
|
||||
if (IsMediaSourceTimelineSyncEnabled(_cachedSongInfo?.PlayerId))
|
||||
{
|
||||
TimelineChanged?.Invoke(this, new TimelineChangedEventArgs(TimeSpan.FromSeconds(_lxMusicPositionSeconds), TimeSpan.FromSeconds(_lxMusicDurationSeconds)));
|
||||
}
|
||||
@@ -547,7 +547,14 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
|
||||
{
|
||||
_logger.LogInformation("LX Music Album Art URL: {url}", picUrl);
|
||||
_lxMusicAlbumArtBytes = await ImageHelper.GetImageBytesFromUrlAsync(picUrl);
|
||||
_SMTCAlbumArtBuffer = _lxMusicAlbumArtBytes.AsBuffer();
|
||||
if (_lxMusicAlbumArtBytes != null)
|
||||
{
|
||||
_SMTCAlbumArtBuffer = _lxMusicAlbumArtBytes.AsBuffer();
|
||||
}
|
||||
else
|
||||
{
|
||||
_SMTCAlbumArtBuffer = null;
|
||||
}
|
||||
UpdateAlbumArt();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ namespace BetterLyrics.WinUI3.ViewModels
|
||||
{
|
||||
var lyricsParser = new LyricsParser();
|
||||
lyricsParser.Parse(
|
||||
AppSettings.MappedSongSearchQueries.ToList(),
|
||||
[MappedSongSearchQuery ?? new()],
|
||||
MappedSongSearchQuery?.OriginalTitle ?? "",
|
||||
MappedSongSearchQuery?.OriginalArtist ?? "",
|
||||
MappedSongSearchQuery?.OriginalAlbum ?? "",
|
||||
|
||||
Reference in New Issue
Block a user