mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-22 05:11:20 -08:00
fix(auto-thumbnail): [PKG-AUTO-THUMB-12] release stalled metadata loads
This commit is contained in:
1 parent
d3aa4bbfe4
commit
42ddead0cd
20 files changed
+6048
-20
No files matched your search
@@ -317,10 +317,19 @@ function extract(job, config) {
|
||||
const video = createVideo(job);
|
||||
if (!job.active())
|
||||
return;
|
||||
let metadataTimer = null;
|
||||
const clearMetadataTimer = () => {
|
||||
const previous = metadataTimer;
|
||||
metadataTimer = null;
|
||||
if (previous !== null)
|
||||
clearTimeout(previous);
|
||||
};
|
||||
job.own(clearMetadataTimer);
|
||||
video.onerror = job.guard(() => {
|
||||
throw video.error || new Error("Auto-thumbnail media failed to load");
|
||||
});
|
||||
video.onloadedmetadata = job.guard(() => {
|
||||
clearMetadataTimer();
|
||||
video.onloadedmetadata = null;
|
||||
const duration = video.duration;
|
||||
const videoHeight = video.videoHeight;
|
||||
@@ -379,8 +388,17 @@ function extract(job, config) {
|
||||
});
|
||||
seek();
|
||||
});
|
||||
if (job.active())
|
||||
video.src = config.url;
|
||||
if (!job.active())
|
||||
return;
|
||||
metadataTimer = setTimeout(job.guard(() => {
|
||||
if (metadataTimer !== null)
|
||||
throw new Error("Auto-thumbnail metadata timed out");
|
||||
}), 3e4);
|
||||
if (!job.active()) {
|
||||
clearMetadataTimer();
|
||||
return;
|
||||
}
|
||||
video.src = config.url;
|
||||
}
|
||||
function artplayerPluginAutoThumbnail(option) {
|
||||
return async (art) => {
|
||||
|
||||
Reference in new issue
Block a user