RTCPeerConnection: pendingLocalDescription 屬性

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2020 年 1 月⁩ 起,所有主流瀏覽器均已支援。

RTCPeerConnection 介面的只讀屬性 pendingLocalDescription 返回一個 RTCSessionDescription 物件,該物件描述了連線本地端的待處理配置更改。

這並不描述連線當前的實際狀態,而是描述它在不久的將來可能存在的方式。請使用 RTCPeerConnection.currentLocalDescriptionRTCPeerConnection.localDescription 來獲取端點的當前狀態。有關差異的詳細資訊,請參閱 WebRTC 連線頁面中的 待處理和當前描述

如果本地描述更改正在進行中,則這是一個描述建議配置的 RTCSessionDescription 物件。否則,將返回 null

示例

此示例檢查 pendingLocalDescription 以確定是否正在處理描述更改。

js
const pc = new RTCPeerConnection();
// …
const sd = pc.pendingLocalDescription;
if (sd) {
  // There's a description change underway!
} else {
  // No description change pending
}

規範

規範
WebRTC:瀏覽器中的即時通訊
# dom-peerconnection-pendinglocaldesc

瀏覽器相容性

注意: pendingLocalDescriptioncurrentLocalDescription 新增到 WebRTC 規範是一個相對較新的功能。在不支援這些屬性的瀏覽器中,只有 localDescription 可用。

另見