帮你快速理解、总结文档立即下载

TXIoTMonitorSession

最近更新时间:2026-11-03 19:02:36
我的收藏

概述

TXIoTMonitorSession 负责拉取设备实时监控画面,包括开始/停止会话、远端拉流与清晰度切换、与设备进行对讲、云台控制、截图。TXIoTMonitorSession 通过 TXIoTEngine.getMonitorSession 获取实例,需在登录成功后调用。
说明:
回调模型:监控事件通过 addListener 注册的监听器对象回调,只需实现自己关心的回调方法即可,公共类型与错误码定义见 TXIoTEngineDef。

方法列表

方法签名
描述
添加实时监控事件监听器。
移除实时监控事件监听器。
设置 iot-player 的组件 ID
开启实时监控。
停止实时监控。
开始渲染远端视频流。
停止渲染远端视频流。
切换远端视频流类型(高清/标清)。
静音/取消静音单路远端音频。
静音/取消静音所有远端音频。
开启本地音频采集和推送(用于实现对讲功能)。
关闭本地音频采集和推送。
静音/取消静音本地音频。
开启本地视频采集和推送。
关闭本地视频采集和推送。
发送云台控制指令。
对当前正在观看的通道进行截图。

addListener

addListener
addListener
(TXIoTMonitorSessionListener listener)
添加监控事件回调
参数
描述
listener
TXIoTMonitorSessionListener;监听器实例。

removeListener

removeListener
removeListener
(TXIoTMonitorSessionListener listener)
移除监控事件回调
参数
描述
listener
TXIoTMonitorSessionListener;监听器实例。

setIoTPlayer

setIoTPlayer
setIoTPlayer
(channelId, iotPlayerComponentId)
绑定渲染组件
参数
描述
channelId
number;通道 ID。
iotPlayerComponentId
string;iot-player 组件 ID。

startSession

startSession
startSession
(deviceId)
开启实时监控
参数
描述
deviceId
TXIoTDeviceId;设备标识(含 productId / deviceName)。

stopSession

stopSession
stopSession
()
停止实时监控

startRemoteView

startRemoteView
startRemoteView
(channelId, streamType)
开始渲染远端视频流
参数
描述
channelId
number;通道 ID。
streamType
TXIoTStreamType;视频流类型(高清/标清)。

stopRemoteView

stopRemoteView
stopRemoteView
(channelId)
停止渲染远端视频流
参数
描述
channelId
number;通道 ID。

switchRemoteStream

switchRemoteStream
switchRemoteStream
(channelId, streamType)
切换远端视频流类型(高清/标清)
参数
描述
channelId
number;通道 ID。
streamType
TXIoTStreamType;视频流类型(高清/标清)。

muteRemoteAudio

muteRemoteAudio
muteRemoteAudio
(channelId, boolean mute)
静音/取消静音单路远端音频
参数
描述
channelId
number;通道 ID。
mute
boolean;是否静音。

muteAllRemoteAudio

muteAllRemoteAudio
muteAllRemoteAudio
(mute)
静音/取消静音所有远端音频
参数
描述
mute
boolean;是否静音。

startLocalAudio

startLocalAudio
startLocalAudio
()
开启本地音频采集和推送(用于实现对讲功能)

stopLocalAudio

stopLocalAudio
stopLocalAudio
()
停止本地音频采集和推送

muteLocalAudio

muteLocalAudio
muteLocalAudio
(mute)
静音/取消静音本地音频
参数
描述
mute
boolean;是否静音。

startLocalVideo

startLocalVideo
startLocalVideo
(videoEncoderParams)
开启本地视频采集和推送
参数
描述
videoEncoderParams
TXIoTVideoEncoderParams;视频编码参数。

stopLocalVideo

stopLocalVideo
stopLocalVideo
()
停止本地视频采集和推送

sendPTZCommand

sendPTZCommand
sendPTZCommand
(channelId, command, speed)
发送云台控制指令
参数
描述
channelId
number;通道 ID。
command
TXIoTPTZCommand;云台控制指令。
speed
number;云台运动速度。

takeSnapshot

takeSnapshot
takeSnapshot
(channelId)
对当前正在观看的通道进行截图
参数
描述
channelId
number;通道 ID。

监控事件回调

TXIoTMonitorSessionListener
回调方法
说明
onError(channelId: Number, code: Number, msg: String)
监控发生错误。
onSessionEstablished()
监控会话建立成功。
onSessionReconnecting()
会话重连中。
onSessionRecovery()
会话恢复成功。
onRemoteStreamAvailable(channelId: Number, available: boolean)
远端流可用性变化。
onRenderFirstFrame(channelId: Number)
首帧渲染完成。
onPlayStateChanged(channelId: Number, state: Number)
播放状态变化。状态类型为 TXIoTPlayState。
onSnapshotComplete(channelId: Number, imagePath: String)
截图完成,成功时 imagePath 非 null。

监控相关数据结构与枚举

TXIoTStreamType

TXIoTStreamType
枚举
说明
HD(0)
高清
SD(1)
标清

TXIoTPTZCommand

TXIoTPTZCommand
枚举
说明
UP(0)
上
DOWN(1)
下
LEFT(2)
左
RIGHT(3)
右
ZOOM_IN(4)
变焦放大
ZOOM_OUT(5)
变焦缩小
STOP(6)
停止

TXIoTPlayState

TXIoTPlayState
枚举
说明
PLAYING(0)
正在播放
LOADING(1)
加载中
STOPPED(2)
已停止

TXIoTVideoResolution

TXIoTVideoResolution
枚举
说明
RESOLUTION_640_360(0)
横屏 640×360
RESOLUTION_960_540(1)
横屏 960×540
RESOLUTION_1280_720(2)
横屏 1280×720
RESOLUTION_1920_1080(3)
横屏 1920×1080
RESOLUTION_360_640(4)
竖屏 360×640
RESOLUTION_540_960(5)
竖屏 540×960
RESOLUTION_720_1280(6)
竖屏 720×1280
RESOLUTION_1080_1920(7)
竖屏 1080×1920

TXIoTVideoEncoderParams

TXIoTVideoEncoderParams
字段
说明
resolution
视频编码分辨率。