SourceBuffer: phương thứcappendBufferAsync()
Note: This feature is available in Dedicated Web Workers.
Non-standard: This feature is not standardized. We do not recommend using non-standard features in production, as they have limited browser support, and may change or be removed. However, they can be a suitable alternative in specific cases where no standard option exists.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Phương thức appendBufferAsync()
của giao diện SourceBuffer bắt đầu quá trình xử lý không đồng bộ
nối thêm dữ liệu phân đoạn phương tiện từ ArrayBuffer,
một đối tượng TypedArray hoặc một DataView đối với đối tượng SourceBuffer.
Nó trả về Promise được đáp ứng sau khi bộ đệm được thêm vào.
Cú pháp
appendBufferAsync(source)
Thông số
source-
Đối tượng
ArrayBuffer,TypedArrayhoặcDataViewchứa dữ liệu phân đoạn phương tiện bạn muốn thêm vàoSourceBuffer.
Giá trị trả về
Một Promise được đáp ứng khi bộ đệm được thêm thành công vào đối tượng SourceBuffer,
hoặc null nếu không thể bắt đầu yêu cầu.
Ví dụ
Hàm async ví dụ đơn giản này, fillSourceBuffer(), lấy làm đầu vào
tham số buffer, ArrayBuffer, TypedArray hoặc DataView và a
Đối tượng SourceBuffer để nối thêm phương tiện nguồn từ bộ đệm vào.
async function fillSourceBuffer(buffer, msBuffer) {
try {
while (true) {
await msBuffer.appendBufferAsync(buffer);
}
} catch (e) {
handleException(e);
}
}
Thông số kỹ thuật
Tính năng này không phải là một phần của bất kỳ thông số kỹ thuật nào. Nó không đi đúng hướng để trở thành một tiêu chuẩn.