MediaTrackSupportedConstraints

MediaTrackSupportedConstraints 字典建立了 用户代理 或浏览器在其对 MediaStreamTrack 对象实现中所识别的可约束属性列表。符合 MediaTrackSupportedConstraints 的对象由 MediaDevices.getSupportedConstraints() 返回。

由于 WebIDL 中接口定义的处理方式,如果在请求时指定了某个约束但该约束不受支持,则不会发生错误。相反,将应用指定的约束,并将任何未识别的约束从请求中移除。这可能导致难以调试的混淆错误,因此,如果您需要区分静默忽略约束和约束被接受,请务必在使用 getSupportedConstraints() 检索此信息后再尝试设置约束。

实际的约束集使用基于 MediaTrackConstraints 字典的对象来描述。

要了解有关约束工作原理的更多信息,请参阅 功能、约束和设置

实例属性

对象上将存在以下属性的某些组合(但不一定是全部)。

aspectRatio

如果当前环境中支持 aspectRatio 约束,则为 true

autoGainControl

如果当前环境中支持 autoGainControl 约束,则为 true

channelCount

如果当前环境中支持 channelCount 约束,则为 true

deviceId

如果当前环境中支持 deviceId 约束,则为 true

echoCancellation

如果当前环境中支持 echoCancellation 约束,则为 true

facingMode

如果当前环境中支持 facingMode 约束,则为 true

frameRate

如果当前环境中支持 frameRate 约束,则为 true

groupId

如果当前环境中支持 groupId 约束,则为 true

height

如果当前环境中支持 height 约束,则为 true

latency

如果当前环境中支持 latency 约束,则为 true

noiseSuppression

如果当前环境中支持 noiseSuppression 约束,则为 true

restrictOwnAudio

如果当前环境中支持 restrictOwnAudio 约束,则为 true

resizeMode

如果当前环境中支持 resizeMode 约束,则为 true

sampleRate

如果当前环境中支持 sampleRate 约束,则为 true

sampleSize

如果当前环境中支持 sampleSize 约束,则为 true

suppressLocalAudioPlayback

如果当前环境中支持 suppressLocalAudioPlayback 约束,则为 true

volume 已弃用 非标准

如果当前环境中支持 volume 约束,则为 true

width

如果当前环境中支持 width 约束,则为 true

共享屏幕轨道特有的实例属性

对于包含用户屏幕视频源的轨道,除了可用于视频轨道的属性外,可能还会包含以下附加属性:

displaySurface

如果当前环境中支持 displaySurface 约束,则为 true

logicalSurface

如果当前环境中支持 logicalSurface 约束,则为 true

规范

规范
媒体捕获和流
# media-track-supported-constraints

另见