DisplayMediaStreamConstraints.audio - Web APIs 编辑
The DisplayMediaStreamConstraints
dictionary's audio
property is used to specify whether or not to request that the MediaStream
containing screen display contents also include an audio track. This value may be a Boolean, where true
indicates that an audio track should be included an false
(the default) indicates that no audio should be included in the stream.
More precise control over the audio data may be exercised by instead providing a MediaTrackConstraints
object, which is used to process the audio prior to adding it to the stream.
Note: The specification for the Screen Capture API does not define what the contents of the audio track should be. This is left up to the user agent to decide. Likely sources are the computer's system audio output and the user's microphone, but there is no way to specify which source to use.
Syntax
displayMediaStreamConstraints.audio = allowAudioFlag; displayMediaStreamConstraints.audio = mediaTrackConstraints; displayMediaStreamConstraints = { audio: allowAudioFlag|mediaTrackConstraints; }
Value
The value may be either a Boolean or a MediaTrackConstraints
object.
If a Boolean is specified, a value of true
indicates that an audio track should be included in the stream returned by getDisplayMedia()
, if an appropriate audio source exists and the user agent supports audio on display media. A value of false
—the default—indicates that no audio track is to be included in the stream.
If a MediaTrackConstraints
object is given, and an audio source is available, an audio track matching the settings given in the constraints object is included in the MediaStream
returned by getDisplayMedia()
.
If no audio source is available, or the user agent doesn't support audio tracks with getDisplayMedia()
, the returned MediaStream
has no audio track, but no error occurs. The audio track is always considered optional.
Example
Specifications
Specification | Status | Comment |
---|---|---|
Screen Capture The definition of 'DisplayMediaStreamConstraints.audio' in that specification. | Working Draft | Initial definition |
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论