Table of Contents
onNewCallObject()
wrtc.onNewCallObject() is an event function called when a new call object has been created.
You can use this event to eg set correct video element to display received video on.
Occurs
A new call object has been created by wrtc.
Arguments
wrtc.onNewCallObject(callobj)
- callobj - the new call object created
Return value
Ignored.
Example
wrtc.onNewCallObject = function(callobj) {
...
var video = document.createElement('video');
video.autoplay = "autoplay";
callobj.remoteVideo = video;
...
}
Advanced
You can also store additional data you need to keep about the call. For example if you want to display the partner's name in a div you can add:
wrtc.onNewCallObject = function(callobj) {
...
var div = document.createElement('div');
div.innerHTML = callobj.getPartner();
callobj.user = {};
callobj.user.name = div;
...
}
You can use callobj.user to store any amount of HTML elements or other data you want about the call.
Then, if you want to access that data in for example a wrtc.onTalking() event you can use the call object provided as an argument to access your data:
wrtc.onTalking = function(callobj) {
...
callobj.user.name.innerHTML = "Connected to " + callobj.getPartner();
...
}