mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-24 23:51:20 -08:00
add getScreenshotBlobUrl
This commit is contained in:
1 parent
078507356a
commit
965e3e008f
5 files changed
+51
-5
No files matched your search
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user