build all

Refactor utility functions for improved readability and consistency

- Updated compatibility.js to use consistent line endings and formatting.
- Refactored component.js for better readability and structure, including consistent use of arrow functions and binding.
- Simplified dom.js functions with consistent formatting and improved readability.
- Enhanced emitter.js with consistent formatting and arrow function usage.
- Streamlined error.js for improved readability and consistency.
- Refactored file.js to use consistent formatting and improved readability.
- Improved format.js functions for better readability and consistency.
- Updated index.js to maintain consistent export formatting.
- Refactored property.js for improved readability and consistency.
- Enhanced subtitle.js with consistent formatting and improved readability.
- Refactored time.js for better readability and consistent formatting.

fix: update lint script to target only source files for consistency

Revert "fix: restore export statements for various plugins and update type definitions for better clarity"

This reverts commit b5e969d81ec765cd8a34b06e6ef4f232ef25087f.

fix: restore export statements for various plugins and update type definitions for better clarity

Refactor type definitions to use interfaces instead of type aliases for better extensibility and clarity across i18n, icons, option, player, quality, setting, subtitle, template, and utils modules.
This commit is contained in:
Harvey Zack committed 2025-08-03 13:17:33 +08:00
1 parent 532dd67cfd
commit 35ad9883af
447 files changed
+18248 -17946

No files matched your search

@@ -1,67 +1,68 @@
function create({ url, width, number }, callback) {
const video = document.createElement('video');
video.crossOrigin = 'anonymous';
video.src = url;
const video = document.createElement('video')
video.crossOrigin = 'anonymous'
video.src = url
video.onloadedmetadata = () => {
const duration = video.duration;
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
const height = Math.floor((width * video.videoHeight) / video.videoWidth);
video.onloadedmetadata = () => {
const duration = video.duration
const canvas = document.createElement('canvas')
const ctx = canvas.getContext('2d')
const height = Math.floor((width * video.videoHeight) / video.videoWidth)
canvas.width = width * 10;
canvas.height = height * Math.ceil(number / 10);
canvas.width = width * 10
canvas.height = height * Math.ceil(number / 10)
let blobUrl = null;
let blobUrl = null
function seekAndDraw(index) {
canvas.toBlob((blob) => {
URL.revokeObjectURL(blobUrl);
blobUrl = URL.createObjectURL(blob);
function seekAndDraw(index) {
canvas.toBlob((blob) => {
URL.revokeObjectURL(blobUrl)
blobUrl = URL.createObjectURL(blob)
callback({
url: blobUrl,
height: height,
});
}, 'image/jpeg');
callback({
url: blobUrl,
height,
})
}, 'image/jpeg')
if (index >= number) return;
video.currentTime = (duration * index) / number;
if (index >= number)
return
video.currentTime = (duration * index) / number
video.onseeked = () => {
ctx.drawImage(video, (index % 10) * width, Math.floor(index / 10) * height, width, height);
seekAndDraw(index + 1);
};
}
video.onseeked = () => {
ctx.drawImage(video, (index % 10) * width, Math.floor(index / 10) * height, width, height)
seekAndDraw(index + 1)
}
}
seekAndDraw(0);
};
seekAndDraw(0)
}
}
export default function artplayerPluginAutoThumbnail(option) {
return async (art) => {
art.on('video:loadedmetadata', () => {
const url = option.url || art.option.url;
const width = option.width || 160;
const number = option.number || 100;
const scale = option.scale || 1;
create({ url, width, number }, (config) => {
art.thumbnails = {
...config,
column: 10,
number,
width,
scale,
};
});
});
return async (art) => {
art.on('video:loadedmetadata', () => {
const url = option.url || art.option.url
const width = option.width || 160
const number = option.number || 100
const scale = option.scale || 1
create({ url, width, number }, (config) => {
art.thumbnails = {
...config,
column: 10,
number,
width,
scale,
}
})
})
return {
name: 'artplayerPluginAutoThumbnail',
};
};
return {
name: 'artplayerPluginAutoThumbnail',
}
}
}
if (typeof window !== 'undefined') {
window['artplayerPluginAutoThumbnail'] = artplayerPluginAutoThumbnail;
window.artplayerPluginAutoThumbnail = artplayerPluginAutoThumbnail
}