mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-09 00:33:46 +02:00
Clarify and better error messages
This commit is contained in:
+13
-3
@@ -553,7 +553,12 @@ export class VideoSample implements Disposable {
|
|||||||
alpha: isFirefox(), // Firefox has VideoFrame glitches with opaque canvases
|
alpha: isFirefox(), // Firefox has VideoFrame glitches with opaque canvases
|
||||||
willReadFrequently: true,
|
willReadFrequently: true,
|
||||||
});
|
});
|
||||||
assert(context);
|
if (!context) {
|
||||||
|
throw new Error(
|
||||||
|
'OffscreenCanvas must have support for the \'2d\' context in order to create a VideoSample from'
|
||||||
|
+ ' this data.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Draw it to a canvas
|
// Draw it to a canvas
|
||||||
context.drawImage(data, 0, 0);
|
context.drawImage(data, 0, 0);
|
||||||
@@ -852,7 +857,7 @@ export class VideoSample implements Disposable {
|
|||||||
} else {
|
} else {
|
||||||
const canvas = this._data;
|
const canvas = this._data;
|
||||||
const context = canvas.getContext('2d');
|
const context = canvas.getContext('2d');
|
||||||
assert(context);
|
assert(context); // We already got it earlier so it's definitely available
|
||||||
|
|
||||||
const imageData = context.getImageData(0, 0, this.codedWidth, this.codedHeight);
|
const imageData = context.getImageData(0, 0, this.codedWidth, this.codedHeight);
|
||||||
|
|
||||||
@@ -1503,7 +1508,12 @@ export class VideoSample implements Disposable {
|
|||||||
const context = canvas.getContext('2d', {
|
const context = canvas.getContext('2d', {
|
||||||
alpha: true,
|
alpha: true,
|
||||||
}) as CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
|
}) as CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
|
||||||
assert(context);
|
if (!context) {
|
||||||
|
throw new Error(
|
||||||
|
'The \'2d\' canvas context is required to transform VideoSamples. Register a custom transformer using'
|
||||||
|
+ ' registerVideoSampleTransformer to work around this limitation.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (description.alpha === 'discard') {
|
if (description.alpha === 'discard') {
|
||||||
context.fillStyle = 'black';
|
context.fillStyle = 'black';
|
||||||
|
|||||||
Reference in New Issue
Block a user