This commit is contained in:
the1812 2019-05-27 15:09:52 +08:00
parent 26bfcaea8e
commit 6c69cda67c
5 changed files with 15 additions and 11 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -14,19 +14,21 @@ class Screenshot {
canvas.height = this.video.videoHeight;
const context = canvas.getContext("2d");
if (context === null) {
throw new Error("视频截图失败: canvas 未创建或创建失败.");
logError("视频截图失败: canvas 未创建或创建失败.");
return;
}
context.drawImage(this.video, 0, 0);
canvas.toBlob(blob => {
if (blob === null) {
throw new Error("视频截图失败: 创建 blob 失败.");
logError("视频截图失败: 创建 blob 失败.");
return;
}
this.blob = blob;
this.url = URL.createObjectURL(blob);
}, "image/png");
}
get filename() {
return `${getFriendlyTitle()} @${this.time}-${this.timeStamp.toString()}.png`;
return `${getFriendlyTitle()} @${this.time.replace(/:/g, "-")} ${this.timeStamp.toString()}.png`;
}
get id() {
return this.videoTime.toString() + this.timeStamp.toString();

View File

@ -22,14 +22,16 @@ class Screenshot
const context = canvas.getContext("2d");
if (context === null)
{
throw new Error("视频截图失败: canvas 未创建或创建失败.");
logError("视频截图失败: canvas 未创建或创建失败.");
return;
}
context.drawImage(this.video, 0, 0);
canvas.toBlob(blob =>
{
if (blob === null)
{
throw new Error("视频截图失败: 创建 blob 失败.");
logError("视频截图失败: 创建 blob 失败.");
return;
}
this.blob = blob;
this.url = URL.createObjectURL(blob);
@ -37,7 +39,7 @@ class Screenshot
}
get filename()
{
return `${getFriendlyTitle()} @${this.time}-${this.timeStamp.toString()}.png`;
return `${getFriendlyTitle()} @${this.time.replace(/:/g, "-")} ${this.timeStamp.toString()}.png`;
}
get id()
{