MediaTrackSupportedConstraints: volume property
Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
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.
Thuộc tính volume của từ điển MediaTrackSupportedConstraints là giá trị Boolean chỉ đọc có mặt (và được đặt thành true) trong đối tượng được trả về bởi MediaDevices.getSupportedConstraints() khi và chỉ khi user agent hỗ trợ ràng buộc volume. Nếu ràng buộc không được hỗ trợ, nó không được đưa vào danh sách, vì vậy giá trị này sẽ không bao giờ là false.
Bạn có thể truy cập từ điển các ràng buộc được hỗ trợ bằng cách gọi navigator.mediaDevices.getSupportedConstraints().
Giá trị
Thuộc tính này có mặt trong từ điển (và giá trị của nó luôn là true) nếu user agent hỗ trợ ràng buộc volume. Nếu thuộc tính không có mặt, thuộc tính này bị thiếu trong từ điển các ràng buộc được hỗ trợ và bạn sẽ nhận được undefined nếu bạn cố gắng xem giá trị của nó.
Ví dụ
const result = document.getElementById("result");
const supported = navigator.mediaDevices.getSupportedConstraints().volume;
result.textContent = supported ? "Được hỗ trợ!" : "Không được hỗ trợ!";