fix: 修复大屏播放控制链路
前端: - useMqttControl 指令分发补上 play_target(此前被静默丢弃,立即播放无法触发大屏跳转) - MediaScreen 重构 playTarget:pendingTargetRef 统一刷新播放列表路径, 消除与 playlist_changed 重载的竞态(避免跳转被旧索引覆盖) 后端: - storage.add_to_playlist 自动识别 URL 来源(source=url), 修复 URL 媒体加入播放列表后被当本地文件过滤、永远无法播放的问题 - _load 时规范化旧数据(source=None 的 http 条目自动补 url)
This commit is contained in:
+10
-2
@@ -30,7 +30,13 @@ class Storage:
|
||||
def _load(self):
|
||||
if self.data_file.exists():
|
||||
try:
|
||||
return json.loads(self.data_file.read_text("utf-8"))
|
||||
data = json.loads(self.data_file.read_text("utf-8"))
|
||||
# 规范化:URL 来源自动标记(兼容旧数据 source=None 的 URL 条目)
|
||||
for it in data.setdefault("playlist", []):
|
||||
p = it.get("path", "")
|
||||
if p.startswith(("http://", "https://")) and not it.get("source"):
|
||||
it["source"] = "url"
|
||||
return data
|
||||
except Exception:
|
||||
pass
|
||||
return {"settings": dict(DEFAULT_SETTINGS), "playlist": [], "url_media": []}
|
||||
@@ -67,7 +73,9 @@ class Storage:
|
||||
with self._lock:
|
||||
items = self._data.setdefault("playlist", [])
|
||||
if not any(it.get("path") == path for it in items):
|
||||
items.append({"path": path, "source": None, "name": None})
|
||||
# URL 来源自动标记,避免被当作本地文件过滤
|
||||
source = "url" if path.startswith(("http://", "https://")) else None
|
||||
items.append({"path": path, "source": source, "name": None})
|
||||
self._save()
|
||||
|
||||
def remove_from_playlist(self, path):
|
||||
|
||||
Reference in New Issue
Block a user