add getScreenshotBlobUrl

This commit is contained in:
Harvey Zack committed 2019-04-19 14:28:33 +08:00
1 parent 078507356a
commit 965e3e008f
5 files changed
+51 -5

No files matched your search

+20 -1
View File
@@ -14,7 +14,7 @@ export default function screenshotMix(art, player) {
canvas.width = $video.videoWidth;
canvas.height = $video.videoHeight;
canvas.getContext('2d').drawImage($video, 0, 0);
return canvas.toDataURL('image/png');;
return canvas.toDataURL('image/png');
} catch (error) {
notice.show(error);
console.warn(error);
@@ -23,6 +23,25 @@ export default function screenshotMix(art, player) {
},
});
Object.defineProperty(player, 'getScreenshotBlobUrl', {
value: () => {
return new Promise((resolve, reject) => {
try {
const canvas = document.createElement('canvas');
canvas.width = $video.videoWidth;
canvas.height = $video.videoHeight;
canvas.getContext('2d').drawImage($video, 0, 0);
canvas.toBlob(blob => {
resolve(URL.createObjectURL(blob));
});
} catch (error) {
notice.show(error);
reject(error);
}
});
},
});
Object.defineProperty(player, 'screenshot', {
value: () => {
const dataUri = player.getScreenshotDataURL();