CloudHub JSSDK
- Overview
- CloudHubRTC
- CloudHubRTCObject
- Client
- ClientEvent
- ClientLiveTranscoding
- ClientChannelMediaRelayConfig
- Stream
- StreamEvent
- DeviceManager
- Constants
Stream Event
event: camera-access-allowed
Note: This callback notifies the App that the permission to use the local camera has been obtained.
Example:
stream.on("camera-access-allowed", function(){
console.log(“camera-access-allowed”);
});
event: microphone-access-allowed
Note: This callback notifies the App that the local microphone has been used.
Example:
stream.on("microphone-access-allowed", function(){
console.log(“microphone-access-allowed”);
});
event: camera-access-denied
Note: This callback notifies the App that the local camera usage permission has been prohibited.
Example:
stream.on("camera-access-denied", function(){
console.log(“camera-access-denied”);
});
event: microphone-access-denied
Note: This callback notifies the App that the local microphone permission has been prohibited.
Example:
stream.on("microphone-access-denied", function(){
console.log(“microphone-access-denied”);
});
event: stop-screen-sharing
Note: This callback notifies the app that screen sharing has stopped.
Example:
stream.on("stop-screen-sharing", function(){
console.log(“stop-screen-sharing”);
});
event: video-track-ended
Note: The callback notifies the video track that it has stopped.
The reason for the stop may be to pull out, cancel the authorization. See MediaStreamTrack.onended。
Example:
stream.on("video-track-ended", function(){
console.log(“video-track-ended”);
});
event: audio-track-ended
Note: The callback notification audio track has stopped.
The reason for the stop may be to pull out, cancel the authorization. See MediaStreamTrack.onended。
Example:
stream.on("audio-track-ended", function(){
console.log(“audio-track-ended”);
});
event: video-track-mute
Note: This callback notification video track cannot send data.
Note: After testing, some machines / cameras open multiple web pages to enter the channel on the same machine, which will cause the local camera to jam, this event will be triggered, and SDK will automatically re-acquire the camera device. [note: SDK will not automatically reacquire the device for streams created with self-collection attributes (audioSource and videoSource)]
Example:
stream.on("video-track-mute", function(){
console.log(“video-track-mute”);
});
event: audio-track-mute
Note: This callback notification audio track cannot transmit data.
Example:
stream.on("audio-track-mute", function(){
console.log(“audio-track-mute”);
});
event: video-track-unmute
Note: This callback notification video track can once again send data.
See MediaStreamTrack.onunmute。
Example:
stream.on("video-track-unmute", function(){
console.log(“video-track-unmute”);
});
event: audio-track-unmute
Note: This callback notification audio track can once again send data.
See MediaStreamTrack.onunmute。
Example:
stream.on("audio-track-unmute", function(){
console.log(“audio-track-unmute”);
});
event: videoplayer-status-change
Note: This callback notifies the video playback state change.
On Windows, frequent DOM operations may cause the Chrome player to be suspended by the browser. To avoid this, you need to listen for the callback and try to call Stream.resumeVideo to resume playback.
The callback has the following properties.
- isErrorState: Whether there is an error in the playback status
- true: Playback status error
- false: Playback status is normal
- status: Playback status
- “play”: Normal playback
- “aborted”: The player is removed before starting playback
- “paused”: The player is in a stopped state.
- reason: Common values for the reasons for the change in playback status are:
- “playing”: Start playing. See HTMLMediaElement: playing event。
- “stalled”: May be related to the browser playback policy.See stalled event。
- “suspend”: May be related to the browser playback policy.See suspend event。
- “canplay”: The media is ready to play. See canplay event。
- “error”: An error occurred during loading. See error event。
- “playfail”: SDK failed to actively call the play method.
Note: How to access the event details of status,如:stalled event address
Example:
stream.on("videoplayer-status-change", function(evt){
if (evt.isErrorState && evt.status === "paused"){
console.error(`Stream video is paused unexpectedly. Trying to resumeVideo...`);
stream.resumeVideo().then(function(){
console.log(`Stream video is resumed successfully`);
}).catch(function(e){
console.error(`Failed to resumeVideo stream. Error ${e.name} Reason ${e.message}`);
});
}
});
event: audioplayer-status-change
Note: The callback notifies the audio playback of a change in playback status.
On Windows, frequent DOM operations may cause the Chrome player to be suspended by the browser. To avoid this, you need to listen for the callback and try to call Stream.resumeAudio to resume playback.
The callback has the following properties.
- isErrorState: Whether there is an error in the playback status
- true: Error in playback status
- false: Playback status is normal
- status: Playback status
- “play”: Normal playback
- “aborted”: The player is removed before it starts playing
- “paused”: The player is in a stopped state.
- reason: The reason for the change in playback state. This value is usually the name of the event that triggered the playback failure. Common values are:
- “playing”: Start playing. See HTMLMediaElement: playing event。
- “stalled”: May be related to the browser playback policy.See stalled event。
- “suspend”: May be related to the browser playback policy.See suspend event。
- “canplay”: The media is ready to play. See canplay event。
- “error”: An error occurred during loading. See error event。
- “playfail”: SDK failed to actively call the play method.
Note: How to access the event details of status,如:stalled event address
Example:
stream.on("audioplayer-status-change", function(evt){
if (evt.isErrorState && evt.status === "paused"){
console.error(`Stream audio is paused unexpectedly. Trying to resumeAudio...`);
stream.resumeAudio().then(function(){
console.log(`Stream audio is resumed successfully`);
}).catch(function(e){
console.error(`Failed to resumeAudio stream. Error ${e.name} Reason ${e.message}`);
});
}
});
event: stream-video-device-state-change
Note: The callback notifies the camera that the status of the device has changed.
Callback parameter evt structure:
{
isNormalDevice: false,
failinfo:failinfo,
deviceId:deviceId
}
Note: When isNormalDevice is false, failinfo, the data format is {errflag: “NOT_ALLOWED_ERROR”, message: “Permission denied”}。
errflag The following values may appear in the field:
- “NOT_SUPPORT”: The browser is not supported.
- “INVALID_ARG”: Invalid parameter.
- “NOT_ALLOWED_ERROR”: The user refuses to grant the corresponding microphone permissions.
- “NOT_READABL_EERROR”: The microphone is occupied.
- “ABORT_ERROR”: Device abort error.
- “NOT_FOUND_ERROR”: Did not find the device.
- “OVER_CONSTRAINED_ERROR”: The configured constraint cannot meet the requirements.
- “SECURITY_ERROR”: Security error, webpage use of device media is prohibited. Whether this mechanism is turned on or off depends on the preferences of individual users.
- “TYPE_ERROR”: Device constraints are set to false.
- “REQ_TIMEOUT”: Request timeout.
- “UNDEFINED_ERROR”: Undefined error.
Example:
client.on("stream-video-device-state-change", function(evt){
console.log(evt);
});
event: stream-audio-device-state-change
Note: This callback notification microphone device changes.
Callback parameter evt structure:
{
isNormalDevice: false,
failinfo:failinfo,
deviceId:deviceId
}
Note: When isNormalDevice is false, failinfo, the data format is {errflag: “NOT_ALLOWED_ERROR”, message: “Permission denied”}。
errflag The following values may appear in the field:
- “NOT_SUPPORT”: The browser is not supported.
- “INVALID_ARG”: Invalid parameter.
- “NOT_ALLOWED_ERROR”: The user refuses to grant the corresponding microphone permissions.
- “NOT_READABL_EERROR”: The microphone is occupied.
- “ABORT_ERROR”: Device abort error.
- “NOT_FOUND_ERROR”: Did not find the device.
- “OVER_CONSTRAINED_ERROR”: The configured constraint cannot meet the requirements.
- “SECURITY_ERROR”: Security error, webpage use of device media is prohibited. Whether this mechanism is turned on or off depends on the preferences of individual users.
- “TYPE_ERROR”: Device constraints are set to false.
- “REQ_TIMEOUT”: Request timeout.
- “UNDEFINED_ERROR”: Undefined error.
Example:
client.on("stream-audio-device-state-change", function(evt){
console.log(evt);
});