mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-22 05:11:20 -08:00
fix(dash): [PKG-DASH-MENU-01] preserve settings navigation during SDK refresh
This commit is contained in:
1 parent
30f646be97
commit
88ce836f85
21 files changed
+769
-23
No files matched your search
@@ -167,7 +167,22 @@ function createMenu(art, name, icon) {
|
||||
remove("setting");
|
||||
}
|
||||
}
|
||||
return { update, clear };
|
||||
function captureNavigation(active) {
|
||||
const setting = art.setting;
|
||||
const item = setting.find?.(name);
|
||||
const callback = owned.get("setting");
|
||||
if (!active() || !callback || setting.show !== true || item?.onSelect !== callback || !item.selector || setting.active !== item.selector || typeof setting.render !== "function")
|
||||
return;
|
||||
return () => {
|
||||
if (!active() || art.setting !== setting || setting.show !== true || !setting.option || setting.active !== setting.option)
|
||||
return;
|
||||
const replacement = setting.find?.(name);
|
||||
const callback2 = owned.get("setting");
|
||||
if (active() && callback2 && replacement?.onSelect === callback2 && replacement.selector)
|
||||
setting.render?.(replacement.selector);
|
||||
};
|
||||
}
|
||||
return { update, clear, captureNavigation };
|
||||
}
|
||||
const $quality = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" height="18"><path fill="#fff" d="M0 96C0 60.7 28.7 32 64 32l384 0c35.3 0 64 28.7 64 64l0 320c0 35.3-28.7 64-64 64L64 480c-35.3 0-64-28.7-64-64L0 96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6l96 0 32 0 208 0c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"/></svg>';
|
||||
function createSeekRecovery(value, active) {
|
||||
@@ -365,7 +380,18 @@ function artplayerPluginDashControl(option = {}) {
|
||||
const subscriptions = [];
|
||||
const observer = observeSDK({
|
||||
active: (dash) => !closed && !art.isDestroy && art.dash === dash,
|
||||
refresh: update,
|
||||
refresh() {
|
||||
const dash = art.dash;
|
||||
let version = revision;
|
||||
const current = () => !closed && !art.isDestroy && art.dash === dash && revision === version;
|
||||
const restore = quality.captureNavigation(current) || audio.captureNavigation(current);
|
||||
if (!current())
|
||||
return;
|
||||
version++;
|
||||
update();
|
||||
if (current())
|
||||
restore?.();
|
||||
},
|
||||
reset() {
|
||||
const version = ++revision;
|
||||
clear(() => version === revision);
|
||||
|
||||
Reference in new issue
Block a user