mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 19:03:46 +02:00
Add some try-catch
This commit is contained in:
+24
-14
@@ -95,13 +95,18 @@ export class InputVideoTrack extends InputTrack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async canDecode() {
|
async canDecode() {
|
||||||
const decoderConfig = await this._backing.getDecoderConfig();
|
try {
|
||||||
if (!decoderConfig) {
|
const decoderConfig = await this._backing.getDecoderConfig();
|
||||||
|
if (!decoderConfig) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const support = await VideoDecoder.isConfigSupported(decoderConfig);
|
||||||
|
return support.supported === true;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error during decodability check:', error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const support = await VideoDecoder.isConfigSupported(decoderConfig);
|
|
||||||
return support.supported === true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,16 +156,21 @@ export class InputAudioTrack extends InputTrack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async canDecode() {
|
async canDecode() {
|
||||||
const decoderConfig = await this._backing.getDecoderConfig();
|
try {
|
||||||
if (!decoderConfig) {
|
const decoderConfig = await this._backing.getDecoderConfig();
|
||||||
return false;
|
if (!decoderConfig) {
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (decoderConfig.codec.startsWith('pcm-')) {
|
if (decoderConfig.codec.startsWith('pcm-')) {
|
||||||
return true; // Since we decode it ourselves
|
return true; // Since we decode it ourselves
|
||||||
} else {
|
} else {
|
||||||
const support = await AudioDecoder.isConfigSupported(decoderConfig);
|
const support = await AudioDecoder.isConfigSupported(decoderConfig);
|
||||||
return support.supported === true;
|
return support.supported === true;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error during decodability check:', error);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user