human: 如何处理七牛云的实时音视频QNRemoteVideoTrack

gpt: [实时音视频](https://developer.qiniu.com/rtc) > API 文档 > Web >QNRemoteVideoTrack

#  QNRemoteVideoTrack

最近更新时间: 2022-07-14 16:09:54

远端视频 Track

Hierarchy

  * EventEmitter 
    * [QNTrack](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/9076/WebQNTrack)
      * [QNLocalTrack](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/9085/WebQNLocalTrack)
        * [QNLocalVideoTrack](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/9061/WebQNLocalVideoTrack)
          * [QNCameraVideoTrack](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/9068/WebQNCameraVideoTrack)
          * [QNScreenVideoTrack](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/9092/WebQNScreenVideoTrack)
          * [QNCanvasVideoTrack](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/10320/WebQNCanvasVideoTrack)
          * [QNCustomVideoTrack](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/9088/WebQNCustomVideoTrack)
        * [QNLocalAudioTrack](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/9089/WebQNLocalAudioTrack)
          * [QNMicrophoneAudioTrack](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/9064/WebQNMicrophoneAudioTrack)
          * [QNBufferSourceAudioTrack](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/9069/WebQNBufferSourceAudioTrack)
          * [QNCustomAudioTrack](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/9091/WebQNCustomAudioTrack)
      * [QNRemoteTrack](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/9082/WebQNRemoteTrack)
        * QNRemoteVideoTrack 
        * [QNRemoteAudioTrack](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/9087/WebQNRemoteAudioTrack)

Index

Properties

  * trackID
  * userID
  * tag
  * mediaElement
  * isLowStreamEnabled
  * isMultiProfileEnabled

Event

  * mute-state-changed
  * low-stream-state-changed
  * profile-changed

Core Methods

  * play
  * isAudio
  * isVideo
  * isMuted
  * getMediaStreamTrack
  * isSubscribed
  * setLowStream
  * setProfile
  * getCurrentFrameData
  * getStats

Properties

trackID

  * trackID?: string
  * Track ID

对于本地 Track，当且仅当 Track 发布后才可获取到有效的 TrackID；对于远端 Track，可随时获取到有效的 TrackID。

userID

  * userID?: string
  * 用户 ID

tag

  * tag?: string
  * 自定义 tag 文本

mediaElement

  * mediaElement: HTMLVideoElement | HTMLAudioElement | undefined
  * 当前播放元素，当调用 play 方法后，可以通过该属性获取播放的媒体元素

isLowStreamEnabled

  * isLowStreamEnabled: boolean
  * 是否开启了大小流

isMultiProfileEnabled

  * isMultiProfileEnabled: boolean
  * 是否开启了大小流

> 废弃，请使用
> [isLowStreamEnabled](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/9060)
> 替代。

Event

mute-state-changed

  * (isMuted: boolean): void
  * mute 状态变化

> 音视频 Track 静默状态改变时触发此事件。

Parameters

    * isMuted: boolean 

是否 muted

low-stream-state-changed

  * (state: boolean): void
  * 大小流状态变化。

值为 true 表示当前使用的是小流，反之为大流。

    
        track.on('low-stream-state-changed',function(state){
        console.log('low-stream-state-changed', state)
    })

Parameters

    * state: boolean 

大小流状态

profile-changed

  * (profile: [QNTrackProfile](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/9050/WebQNTrackProfile)): void
  * 大小流状态变化
    
        track.on('profile-changed', function(profile){
        console.log('profile-changed', profile)
    })

> 废弃，请使用 [low-stream-state-
> changed](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/9060)
> 替代。

Parameters

    * profile: [QNTrackProfile](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/9050/WebQNTrackProfile)

大小流状态

Core Methods

play

  * public play(container: HTMLElement, config?: QNPlayerConfig): Promise<void>
  * 播放当前 track

Parameters

    * container: HTMLElement 

挂载的 html 容器，SDK 会在该容器下创建 audio 或 video 元素来播放 track

    * Optional config: [QNPlayerConfig](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/10141/WebQNPlayerConfig)

播放配置信息

Returns void

isAudio

  * isAudio(): boolean
  * 是否是音频

Returns boolean

isVideo

  * isVideo(): boolean
  * 是否是视频

Returns boolean

isMuted

  * isMuted(): boolean
  * 是否 mute（静音）

Returns boolean

getMediaStreamTrack

  * getMediaStreamTrack(): MediaStreamTrack | undefined
  * 获取浏览器原生的 MediaStreamTrack 对象

Returns MediaStreamTrack | undefined

isSubscribed

  * isSubscribed(): boolean
  * 是否已订阅

Returns boolean

setLowStream

  * setLowStream(use: boolean): void
  * 是否订阅远端发布的小流

> 可以先通过
> [isLowStreamEnabled](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/9060)
> 判断远端是否开启大小流，再进行设置。
>
>
> 关于大小流详细内容可参阅[视频大小流使用指南](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/10566/video-
> size-flow-web-new)。

Parameters

    * use: boolean 

true 表示使用小流，false 表示使用大流。

Returns void

setProfile

  * setProfile(profile: [QNTrackProfile](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/9050/WebQNTrackProfile)): void
  * 选择订阅视频的大小流

> 废弃，请使用
> [setLowStream](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/9060)
> 替代。

Parameters

    * profile: [QNTrackProfile](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/9050/WebQNTrackProfile)

指定大小流

Returns void

getCurrentFrameData

  * getCurrentFrameData(): string
  * 截取当前视频流数据

Returns string

getStats

  * getStats(): [QNRemoteVideoTrackStats](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/9380/WebQNRemoteVideoTrackStats)
  * 获取流状态数据

Returns
[QNRemoteVideoTrackStats](https://developer.qiniu.com/rtc/9060/WebQNRemoteVideoTrack/9380/WebQNRemoteVideoTrackStats)

以上内容是否对您有帮助？