RTCVideoSourceStats: width 屬性

可用性有限

此特性不是基線特性,因為它在一些最廣泛使用的瀏覽器中不起作用。

RTCVideoSourceStats 字典的 width 屬性表示來自此源的最後一幀的寬度(以畫素為單位)。

在產生第一幀之後,此屬性才會在 stats 物件上定義。

一個正數,表示寬度(以畫素為單位)。

示例

此示例展示瞭如何遍歷 RTCRtpSender.getStats() 返回的 stats 物件以獲取影片源 stats,然後提取 width

js
// where sender is an RTCRtpSender
const stats = await sender.getStats();
let videoSourceStats = null;

stats.forEach((report) => {
  if (report.type === "media-source" && report.kind==="video") {
    videoSourceStats = report;
    break;
  }
});

// Note, test is conditional in case the stats object
// does not include video source stats
const height = videoSourceStats?.width;

規範

規範
WebRTC 統計 API 的識別符號
# dom-rtcvideosourcestats-width

瀏覽器相容性