mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-20 20:21:20 -08:00
fix(dash): [PKG-DASH-SEEK-01] recover paused boundary seeks in SDK 4.5.2
This commit is contained in:
1 parent
442e1dcc96
commit
30f646be97
22 files changed
+1725
-57
No files matched your search
@@ -170,6 +170,59 @@ function createMenu(art, name, icon) {
|
||||
return { update, clear };
|
||||
}
|
||||
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) {
|
||||
const sdk = value;
|
||||
try {
|
||||
if (typeof sdk.getVersion !== "function" || sdk.getVersion() !== "4.5.2")
|
||||
return;
|
||||
if (typeof sdk.getVideoElement !== "function" || typeof sdk.getActiveStream !== "function" || typeof sdk.getDashMetrics !== "function")
|
||||
return;
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
let running = false;
|
||||
return () => {
|
||||
if (running || !active())
|
||||
return;
|
||||
running = true;
|
||||
try {
|
||||
const video = sdk.getVideoElement?.();
|
||||
if (!video?.seeking || !Number.isFinite(video.currentTime))
|
||||
return;
|
||||
const time = video.currentTime;
|
||||
const stream = sdk.getActiveStream?.();
|
||||
const metrics = sdk.getDashMetrics?.();
|
||||
const processors = stream?.getProcessors?.();
|
||||
if (!Array.isArray(processors) || typeof metrics?.getCurrentBufferLevel !== "function" || typeof metrics.addBufferLevel !== "function")
|
||||
return;
|
||||
for (const processor of processors) {
|
||||
if (!active())
|
||||
return;
|
||||
const type = processor.getType?.();
|
||||
if (type !== "audio" && type !== "video")
|
||||
continue;
|
||||
const buffer = processor.getBufferController?.();
|
||||
if (typeof buffer?.getRangeAt !== "function" || typeof buffer.getIsPruningInProgress !== "function" || typeof buffer.getAllRangesWithSafetyFactor !== "function")
|
||||
continue;
|
||||
const cached = metrics.getCurrentBufferLevel(type);
|
||||
const range = buffer.getRangeAt(time);
|
||||
const empty = range === null || range && Number.isFinite(range.end) && range.end <= time;
|
||||
if (!Number.isFinite(cached) || cached <= 0 || !empty || buffer.getIsPruningInProgress() !== false)
|
||||
continue;
|
||||
const removals = buffer.getAllRangesWithSafetyFactor(time);
|
||||
if (!Array.isArray(removals) || removals.length !== 0)
|
||||
continue;
|
||||
if (!active() || sdk.getActiveStream?.() !== stream || sdk.getDashMetrics?.() !== metrics || sdk.getVideoElement?.() !== video || video.currentTime !== time || !video.seeking || !active())
|
||||
return;
|
||||
metrics.addBufferLevel(type, /* @__PURE__ */ new Date(), 0);
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn("ArtPlayer DASH seek buffer refresh failed:", error);
|
||||
} finally {
|
||||
running = false;
|
||||
}
|
||||
};
|
||||
}
|
||||
function observeSDK(options) {
|
||||
let binding;
|
||||
const active = (record) => binding === record && options.active(record.dash);
|
||||
@@ -253,6 +306,9 @@ function observeSDK(options) {
|
||||
record.suspended = false;
|
||||
schedule(record);
|
||||
}]);
|
||||
const recoverSeek = createSeekRecovery(dash, () => active(record) && !record.suspended);
|
||||
if (recoverSeek)
|
||||
entries.push(["playbackSeeking", recoverSeek]);
|
||||
entries.push(["playbackTimeUpdated", () => {
|
||||
if (!active(record) || record.suspended)
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user