feat: Add support for custom file names in screenshot functionality

This commit is contained in:
Harvey Zack committed 2024-07-03 15:56:49 +08:00
1 parent b2796a1f6c
commit caddb2091e
2 files changed
+4 -2

No files matched your search

+1
View File
@@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## [Unreleased]
- 新增 `Artplayer.STYLE` 属性,返回播放器样式文本
- `art.screenshot('your-name')` 截图功能支持自定义文件名字
## [5.1.6] - 2024-6-15
@@ -41,9 +41,10 @@ export default function screenshotMix(art) {
});
def(art, 'screenshot', {
value: async () => {
value: async (name) => {
const dataUri = await art.getDataURL();
download(dataUri, `artplayer_${secondToTime($video.currentTime)}.png`);
const fileName = name || `artplayer_${secondToTime($video.currentTime)}`;
download(dataUri, `${fileName}.png`);
art.emit('screenshot', dataUri);
return dataUri;
},