AudioEncoder: 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 AudioEncoder kiểm tra liệu cấu hình đã cho có được hỗ trợ hay không (tức là liệu các đối tượng AudioEncoder có thể được cấu hình thành công bằng cấu hình đó hay không).
Cú pháp
AudioEncoder.isConfigSupported(config)
Tham số
config-
Đối tượng từ điển được chấp nhận bởi
AudioEncoder.configure
Giá trị trả về
Một Promise được giải quyế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à không có 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 AudioEncoder.isConfigSupported(config);
console.log(
`AudioEncoder's config ${JSON.stringify(support.config)} support: ${
support.supported
}`,
);
}
Thông số kỹ thuật
| Specification |
|---|
| WebCodecs> # dom-audioencoder-isconfigsupported> |