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
joiningorjoinedevents have already occurred.
speak()
Parameters
The config parameter accepts an object of typeMessageConfig, which is a union of the following: TextMessageConfig and StreamMessageConfig.
-
The
AIAvatarStatetransitions toloading. -
When the AIAvatar begins speaking:
a. The
aiavatar-start-speakingevent is triggered. b. TheAIAvatarStatetransitions tospeaking. -
When the AI Avatar finishes speaking:
a. The
aiavatar-stop-speakingevent is triggered. b. TheAIAvatarStatetransitions toidle. -
The AIAvatar’s speech text can be verified through the callback argument of the
aiavatar-messageevent.
- The
RoomStateis notjoinedwhen the method is called. - The
AIAvatarStateis notidlewhen the method is called.
stopSpeaking()
- the
aiavatar-stop-speakingevent is triggered. - The
AIAvatarStatetransitions to idle.
- The
AIAvatarStateis 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
joinedevent 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
joinedevent 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.