new videoRoom(onEvents, domElements, options)
VideoRoom usecase
Parameters:
| Name | Type | Description |
|---|---|---|
onEvents |
object | Event handlers: onCreated, onError, onJoined, onDestroyed, onPeerJoined, onPeerLeft |
domElements |
object | DOM elements: videos |
options |
object | options: stream |
Returns:
VideoRoom methods: createVideoroom, destroyVideoroom, getPeers, joinVideoroom, toggleAudio, toggleVideo
- Type
- Promise
Example
var onEvents = {
onCreated: function(id) {
// Created
},
onError: function(cause, code) {
// Error
},
onJoined: function() {
// Joined
},
onDestroyed: function() {
// Destroyed
},
onPeerJoined: function(id, display) {
// Peer Joined
},
onPeerLeft: function(id, display) {
// Peer Left
}
};
var domElements = {
videos: document.getElementById('videortc-videos') // App container
};
var options = {
stream: {
audioEnabled: true,
videoEnabled: true,
aDeviceId: null,
vDeviceId: null,
voiceProcessor: false
}
};
usecases.videoRoom(onEvents, domElements, options)
.then(function(action) {
// Use Case has been atacched succesfully
...
})
.catch(function(cause) {
// Error attaching the Use Case
console.log("Error Attach " + cause );
})
Methods
-
<inner> closeUsecase()
-
Close the current UseCase. It's recommended combine with disconnect method
Returns:
- Type
- nothing
Example
action.closeUsecase(); myVideoApp.disconnect(); // Recommended
-
<inner> createVideoroom(isPrivate, adminKey, userKey, quality, maxPublishers, isRecord)
-
Creates a new VideoRoom / Conference
Parameters:
Name Type Description isPrivateBoolean Is private?
adminKeystring Administrator Room Key (Destroy)
userKeystring User Room Key (Join)
qualitystring | enum Quality: "high", "medium" or "low"
maxPublishersinteger Number of publishers/peers
isRecordBoolean Record the videoroom
Returns:
- Type
- nothing
Example
action.createVideoroom(true, 'MyP455w0rd', 'Us3rPw', 'medium', 6, false);
-
<inner> destroyVideoroom(id, adminKey)
-
Destroys a Videoroom (Admin key is required)
Parameters:
Name Type Description idinteger VideoRoom Id
adminKeystring Administrator Room Key
Returns:
- Type
- nothing
Example
action.destroyVideoroom(743267423, 'MyP455w0rd');
-
<inner> getPeers()
-
Gets the number of peers/users connected into the current Videoroom
Returns:
Number of peers/users connected into the current Videoroom
- Type
- integer
-
<inner> joinVideoroom(name, idRoom, pin)
-
Join into a VideoRoom
Parameters:
Name Type Description namestring User Name
idRoominteger VideoRoom ID
pinstring Videoroom PIN to Join (Optional)
Returns:
- Type
- nothing
Example
action.joinVideoroom('Mike', 743267423, 'ivr1234'); -
<inner> toggleAudio()
-
Toggle Audio stream (Mute/Unmute)
Returns:
Is audio muted?
- Type
- boolean
Example
action.toggleAudio(); // true or false
-
<inner> toggleVideo()
-
Toggle Video stream (Mute/Unmute)
Returns:
Is video muted?
- Type
- boolean
Example
action.toggleVideo(); // true or false