VmonsterRoom
instance provides a variety of methods to manage and control the interactions and functionalities within the virtual space.
These methods enable developers to automate tasks and enhance user engagement efficiently.
The following are the instance methods.
join()
VmonsterRoom
.
If the method operates successfully, the joined
event will be triggered.
Parameters
The config parameter accepts an object of typeJoinOptions.
- An error will be triggered if the method is called after the
joining
orjoined
events have already occurred.
speak()
Parameters
The config parameter accepts an object of typeMessageConfig
, which is a union of the following: TextMessageConfig
and StreamMessageConfig
.
-
The
AIAvatarState
transitions toloading
. -
When the AIAvatar begins speaking:
a. The
aiavatar-start-speaking
event is triggered. b. TheAIAvatarState
transitions tospeaking
. -
When the AI Avatar finishes speaking:
a. The
aiavatar-stop-speaking
event is triggered. b. TheAIAvatarState
transitions toidle
. -
The AIAvatar’s speech text can be verified through the callback argument of the
aiavatar-message
event.
- The
RoomState
is notjoined
when the method is called. - The
AIAvatarState
is notidle
when the method is called.
stopSpeaking()
- the
aiavatar-stop-speaking
event is triggered. - The
AIAvatarState
transitions to idle.
- The
AIAvatarState
is not speaking when the method is called.
leave()
VmonsterRoom
.
Upon execution, the left
event is triggered immediately.
Error Occurrence
- An error will be triggered if the method is called before the
joined
event has occurred.
addVideo()
<video>
element with the id “aiavatar-video” and adds it if it doesn’t already exist.
Parent Element Determination:
- If an element with the id “aiavatar-video-parent” is found, the video element is added as a child of this element.
- If no such element exists, the video element is added as a child of document.body.
- If a style is provided as input, the video element is added with the specified style applied.
- If no style is provided, the element is added with the following default styles applied.
removeVideo()
unmuteUserAudio()
muteUserAudio()
unPublishUserAudio()
unmuteUserAudio()
.
stt()
- An error will be triggered if the method is called before the
joined
event has occurred.
startRecordingAudio()
- The browser does not support getUserMedia.
- The browser does not support MediaRecorder.
stopRecordingAudio()
- An error will be triggered if the method is called when not currently recording.