Skip to content

Commit

Permalink
feat: createImageBitmap
Browse files Browse the repository at this point in the history
  • Loading branch information
zhw2590582 committed Sep 15, 2024
1 parent 710f947 commit a74e7bb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/assets/example/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

var art = new Artplayer({
container: '.artplayer-app',
url: '/assets/sample/video.mp4',
url: 'https://artplayer.org/assets/sample/video.mp4',
poster: '/assets/sample/poster.jpg',
volume: 0.5,
autoplay: false,
Expand Down
8 changes: 5 additions & 3 deletions docs/uncompiled/artplayer-proxy-canvas/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/uncompiled/artplayer-proxy-canvas/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions packages/artplayer-proxy-canvas/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ export default function artplayerProxyCanvas() {

async function draw() {
try {
const bitmap = await createImageBitmap(video);
ctx.drawImage(bitmap, 0, 0, canvas.width, canvas.height);
bitmap.close();
if (typeof createImageBitmap !== 'undefined') {
const bitmap = await createImageBitmap(video);
ctx.drawImage(bitmap, 0, 0, canvas.width, canvas.height);
bitmap.close();
} else {
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
}
art.emit('artplayerProxyCanvas:draw', ctx);
} catch (error) {
art.emit('artplayerProxyCanvas:error', error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,4 @@ import type Artplayer from 'artplayer';
export = artplayerProxyCanvas;
export as namespace artplayerProxyCanvas;

type Option = (video: HTMLVideoElement, url: String, art: Artplayer) => void;

type Result = HTMLCanvasElement;

declare const artplayerProxyCanvas: (option: Option) => (art: Artplayer) => Result;
declare const artplayerProxyCanvas: () => (art: Artplayer) => HTMLCanvasElement;

0 comments on commit a74e7bb

Please sign in to comment.