AudioDecoder: phương thức tĩnh isConfigSupported()
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Note: This feature is available in Dedicated Web Workers.
Phương thức tĩnh isConfigSupported() của giao diện AudioDecoder kiểm tra xem cấu hình được cung cấp có được hỗ trợ hay không (tức là liệu các đối tượng AudioDecoder có thể được cấu hình thành công bằng cấu hình đó hay không).
Cú pháp
AudioDecoder.isConfigSupported(config)
Tham số
config-
Đối tượng dictionary được
AudioDecoder.configurechấp nhận
Giá trị trả về
Một Promise được hoàn tất với một đối tượng chứa các thành viên sau:
Ngoại lệ
TypeError-
Được ném ra nếu
configđược cung cấp không hợp lệ; tức là thiếu các giá trị bắt buộc (chẳng hạn trườngcodecrỗng) hoặc có các giá trị không hợp lệ (chẳng hạnsampleRateâm).
Ví dụ
Ví dụ sau kiểm tra xem trình duyệt có hỗ trợ một số codec âm thanh hay không.
const codecs = ["mp4a.40.2", "mp3", "alaw", "ulaw"];
const configs = [];
for (const codec of codecs) {
configs.push({
codec,
sampleRate: 48000,
numberOfChannels: 1,
not_supported_field: 123,
});
}
for (const config of configs) {
const support = await AudioDecoder.isConfigSupported(config);
console.log(
`AudioDecoder's config ${JSON.stringify(support.config)} support: ${
support.supported
}`,
);
}
Thông số kỹ thuật
| Specification |
|---|
| WebCodecs> # dom-audiodecoder-isconfigsupported> |