mirror of
https://github.com/jayfunc/BetterLyrics.git
synced 2026-01-12 10:54:55 +08:00
fix: app crash when audio device was not found
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
<Identity
|
||||
Name="37412.BetterLyrics"
|
||||
Publisher="CN=E1428B0E-DC1D-4EA4-ACB1-4556569D5BA9"
|
||||
Version="1.1.221.0" />
|
||||
Version="1.2.222.0" />
|
||||
|
||||
<mp:PhoneIdentity PhoneProductId="ca4a4830-fc19-40d9-b823-53e2bff3d816" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
||||
|
||||
|
||||
@@ -17,12 +17,20 @@ namespace BetterLyrics.WinUI3.Hooks
|
||||
|
||||
static SystemVolumeHook()
|
||||
{
|
||||
_deviceEnumerator = new MMDeviceEnumerator();
|
||||
_defaultDevice = _deviceEnumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
|
||||
|
||||
if (_defaultDevice != null)
|
||||
try
|
||||
{
|
||||
_defaultDevice.AudioEndpointVolume.OnVolumeNotification += AudioEndpointVolume_OnVolumeNotification;
|
||||
_deviceEnumerator = new MMDeviceEnumerator();
|
||||
// 找不到设备会抛出异常,在这里截获它
|
||||
_defaultDevice = _deviceEnumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
|
||||
|
||||
if (_defaultDevice != null)
|
||||
{
|
||||
_defaultDevice.AudioEndpointVolume.OnVolumeNotification += AudioEndpointVolume_OnVolumeNotification;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_defaultDevice = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,27 +3,24 @@ using System;
|
||||
|
||||
namespace BetterLyrics.WinUI3.Models
|
||||
{
|
||||
[Preserve(AllMembers = true)]
|
||||
[Table("FileCache")]
|
||||
public class FileCacheEntity
|
||||
{
|
||||
[PrimaryKey, AutoIncrement]
|
||||
public int Id { get; set; }
|
||||
|
||||
// 【新增】关键字段!
|
||||
// 关联到 MediaFolder.Id。
|
||||
// 作用:
|
||||
// 1. 区分不同配置(即使两个配置连的是同一个 SMB,但在 APP 里视为不同源)。
|
||||
// 2. 删除配置时,可以由 MediaFolderId 快速级联删除所有缓存。
|
||||
// 区分不同配置(即使两个配置连的是同一个 SMB,但在 APP 里视为不同源)。
|
||||
// 删除配置时,可以由 MediaFolderId 快速级联删除所有缓存。
|
||||
[Indexed]
|
||||
public string MediaFolderId { get; set; }
|
||||
|
||||
// 【修改】从 ParentPath 改为 ParentUri
|
||||
// 存储父文件夹的标准 URI (smb://host/share/parent)
|
||||
// 根目录文件的 ParentUri 可以为空,或者等于 MediaFolder 的 Base Uri
|
||||
[Indexed]
|
||||
public string? ParentUri { get; set; }
|
||||
|
||||
// 【核心】标准化的完整 URI (smb://host/share/folder/file.ext)
|
||||
// 确保它是 URL 编码过且格式统一的
|
||||
[Indexed(Unique = true)]
|
||||
public string Uri { get; set; }
|
||||
@@ -38,7 +35,6 @@ namespace BetterLyrics.WinUI3.Models
|
||||
// 记录修改时间,同步时对比使用
|
||||
public DateTime? LastModified { get; set; }
|
||||
|
||||
// ------ 元数据部分 (保持不变) ------
|
||||
public string Title { get; set; } = "";
|
||||
public string Artists { get; set; } = "";
|
||||
public string Album { get; set; } = "";
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Text;
|
||||
|
||||
namespace BetterLyrics.WinUI3.Models
|
||||
{
|
||||
[Preserve(AllMembers = true)]
|
||||
[Table("PlayHistory")]
|
||||
public class PlayHistoryItem
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user