--- title: MediaStream.id slug: Web/API/MediaStream/id translation_of: Web/API/MediaStream/id ---

{{APIRef("WebRTC")}}

MediaStream.id 只读属性,一个包含36个字符的 {{domxref("DOMString")}} ,用来作为这个对象的唯一标识符 (GUID) 。

语法

var id = mediaStream.id;

示例

var p = navigator.mediaDevices.getUserMedia({ audio: true, video: true });

p.then(function(stream) {
   console.log(stream.id);
};)

规范

Specification Status Comment
{{SpecName('Media Capture', '#widl-MediaStream-id', 'MediaStream.id')}} {{Spec2('Media Capture')}} Initial definition.

浏览器兼容性

{{ CompatibilityTable() }}

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{ CompatUnknown() }} {{CompatVersionUnknown}} {{ CompatGeckoDesktop(41) }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}
Feature Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{CompatVersionUnknown}} {{ CompatGeckoMobile(41) }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

相关链接