上QQ阅读APP看书,第一时间看更新
2.2 媒体轨道
我们已经在多个方法中接触到了媒体轨道,媒体流由媒体轨道构成,而媒体轨道则代表着一个能够提供媒体服务的媒体,如音频、视频等。
媒体轨道使用MediaStreamTrack接口管理,MediaStreamTrack的定义如代码清单2-8所示。
代码清单2-8 MediaStreamTrack的定义
interface MediaStreamTrack : EventTarget { readonly attribute DOMString kind; readonly attribute DOMString id; readonly attribute DOMString label; attribute boolean enabled; readonly attribute boolean muted; attribute EventHandler onmute; attribute EventHandler onunmute; readonly attribute MediaStreamTrackState readyState; attribute EventHandler onended; MediaStreamTrack clone(); void stop(); MediaTrackCapabilities getCapabilities(); MediaTrackConstraints getConstraints(); MediaTrackSettings getSettings(); Promise<void> applyConstraints(optional MediaTrackConstraints constraints = {}); };