这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。
RTCPeerConnection
接口的方法 getDefaultIceServers()
返回一个基于 RTCIceServer
字典的对象数组。如果在 RTCPeerConnection
的 RTCConfiguration
中没有设置,该数组指向浏览器缺省使用的ICE servers,前提是浏览器确实存在缺省的ICE servers。然而,浏览器完全不必提供任何的缺省ICE Servers。
语法
var defaultIceServers = RTCPeerConnection.getDefaultIceServers();
返回值
一个 ICE servers 的数组,以基于 RTCIceServer
的对象组成,当没有在 RTCPeerConnection
的设置中进行设置时,浏览器将使用它们。如果浏览器没有提供缺省值,将返回一个空数组,该属性的值永远不是 null
。
例子
var pc = new RTCPeerConnection();
var iceServers = pc.getDefaultIceServers();
if (iceServers.length === 0) {
// Deal with the lack of default ICE servers, possibly by using our own defaults
}
Specifications
Specification | Status | Comment |
---|---|---|
WebRTC Extensions |
Browser compatibility
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.