--- title: RTCPeerConnection.iceConnectionState slug: Web/API/RTCPeerConnection/iceConnectionState translation_of: Web/API/RTCPeerConnection/iceConnectionState ---

{{APIRef("WebRTC")}}{{SeeCompatTable}}

RTCPeerConnection.iceConnectionState 是一个只读属性,用于描述连接的ICE连接状态,返回值为枚举类型。

语法

 var state = peerConnection.iceConnectionState;

返回值

RTCIceConnectionState的返回值为下面列举中的一种:

例子

var pc = new RTCPeerConnection();
var state = pc.iceConnectionState;

规范

Specification Status Comment
{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-iceConnectionState', 'RTCPeerConnection.iceConnectionState') }} {{ Spec2('WebRTC 1.0') }} Initial specification.

浏览器兼容

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{ CompatVersionUnknown() }} [1] {{ CompatVersionUnknown }} [1] {{ CompatNo() }} {{ CompatVersionUnknown() }} {{ CompatUnknown() }}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatNo() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

[1] Though this property is not prefixed, the interface it belongs to is.

参考文档