How to release a call
BeantwortetHello,
I have a web page with two button (Call and release)
The call button works correctly but the release button does not work, I do not know how to retrieve the current call to use it at the time of the release of call, below the code that I use:
ps: I do not work with AngularJS
------------------------------------------------------------
var currentCall = null;
var releaseCall = function releaseCall() {
rainbowSDK.webRTC.release(currentCall );
};
var onWebRTCCallChanged = function onWebRTCCallChanged(__event, call) {
console.log("[DEMO] :: WebRTC Call state changed to " + call.status.value, call);
switch (call.status.value) {
case Call.Status.RINGING_INCOMMING.value:
if (call.remoteMedia & Call.Media.VIDEO) {
answerInVideo(call);
}
else {
answerInAudio(call);
}
break;
case Call.Status.ACTIVE.value:
if (call.remoteMedia & Call.Media.VIDEO) {
displayRemoteVideo(call);
}
else {
hideRemoteVideo(call);
}
if (call.localMedia & Call.Media.VIDEO) {
displayLocalVideo(call);
} else {
hideLocalVideo(call);
}
$scope.isInCommunication = true;
break;
case Call.Status.UNKNOWN.value:
hideLocalVideo();
hideRemoteVideo(call);
break;
default:
console.log("[DEMO] :: Nothing to do with that event...");
break;
}
currentCall = call;
};
var answerInVideo = function answerInVideo(call) {
console.log("[DEMO] :: Answer in video");
rainbowSDK.webRTC.answerInVideo(call);
};
var answerInAudio = function answerInAudio(call) {
console.log("[DEMO] :: Answer in audio");
rainbowSDK.webRTC.answerInAudio(call);
};
var displayRemoteVideo = function displayRemoteVideo(call) {
console.log("[DEMO] :: Display remote video");
rainbowSDK.webRTC.showRemoteVideo(call);
};
var hideRemoteVideo = function hideRemoteVideo(call) {
console.log("[DEMO] :: Hide remote video");
rainbowSDK.webRTC.hideRemoteVideo(call);
};
var displayLocalVideo = function displayLocalVideo() {
console.log("[DEMO] :: Display local video");
rainbowSDK.webRTC.showLocalVideo();
};
var hideLocalVideo = function hideLocalVideo() {
console.log("[DEMO] :: Hide local video");
rainbowSDK.webRTC.hideLocalVideo();
};
$(document).on(rainbowSDK.webRTC.RAINBOW_ONWEBRTCCALLSTATECHANGED, onWebRTCCallChanged);
-
Hi,
Could you please also provide browser's Debug console ?
I think there may be an exception somewhere which prevents yourcurrentCall = call;
As you are no using Angular, did you see the way to retrieve the "Call" Object described there
https://hub.openrainbow.com/#/documentation/doc/sdk/web/guides/4-Make_audio_and_video_call ?I mean: at top of your code
var Call = angular.element(document.querySelector('body')).injector().get('Call');
-
thank you for your reply
I already tried with the line "var Call = angular.element (document.querySelector ('body')). injector (). get ('Call');"
when to call the variable "Call"?
my code is:
var Call = angular.element (document.querySelector ('body')). injector (). get ('Call');
var currentCall = null
function hang up () {
alert ( "hanging up");
var releaseCall = function releaseCall (call) {
/ * Call this API to release the call * /
rainbowSDK.webRTC.release (currentCall);
};
var onWebRTCCallChanged = function onWebRTCCallChanged (event, call) {
switch (call.status.value) {
Call.Status.RINGING_INCOMMING.value box:
if (call.remoteMedia & Call.Media.VIDEO) {
answerInVideo (call);
}
else {
answerInAudio (call);
}
break;
Call.Status.ACTIVE.value box:
if (call.remoteMedia & Call.Media.VIDEO) {
displayRemoteVideo (call);
}
else {
hideRemoteVideo (call);
}
if (call.localMedia & Call.Media.VIDEO) {
displayLocalVideo (call);
} else {
hideLocalVideo (call);
}
$ scope.isInCommunication = true;
break;
Call.Status.UNKNOWN.value box:
hideLocalVideo ();
hideRemoteVideo (call);
break;
default:
console.log ("[DEMO] :: Nothing to do with that event ...");
break;
}
currentCall = call;
};
var answerInVideo = function answerInVideo (call) {
console.log ("[DEMO] :: Answer in video");
rainbowSDK.webRTC.answerInVideo (call);
};
var answerInAudio = function answerInAudio (call) {
console.log ("[DEMO] :: Answer in audio");
rainbowSDK.webRTC.answerInAudio (call);
};
var displayRemoteVideo = function displayRemoteVideo (call) {
console.log ("[DEMO] :: Display remote video");
rainbowSDK.webRTC.showRemoteVideo (call);
};
var hideRemoteVideo = function hideRemoteVideo (call) {
console.log ("[DEMO] :: Hide remote video");
rainbowSDK.webRTC.hideRemoteVideo (call);
};
var displayLocalVideo = function displayLocalVideo () {
console.log ("[DEMO] :: Display local video");
rainbowSDK.webRTC.showLocalVideo ();
};
var hideLocalVideo = function hideLocalVideo () {
console.log ("[DEMO] :: Hide local video");
rainbowSDK.webRTC.hideLocalVideo ();
};
$ (document) .on (rainbowSDK.webRTC.RAINBOW_ONWEBRTCCALLSTATECHANGED, onWebRTCCallChanged);
}browser's Debug console:can you look at my code ? -
Hi,
var Call = angular.element (document.querySelector ('body')). injector (). get ('Call');
will only get the Call object from angular, in ordre to be able to get the constant in the function onWebRTCCallChanged (event, call)
Move it perhaps inside the onWebRTCCallChanged (event, call)What do you mean "it is always empty" ?
I would also move your (remove it forme where it is)
currentCall = call;
inside your code
var answerInVideo = function answerInVideo (call) {
and
var answerInAudio = function answerInAudio (call) {
Pascal
-
Hi Pascal,
The call passes, but the identifier of the call, retrieved via the method .... get (call), is not exploitable via the release (call) method called when you release. Yet this is the identifier of the call (call) in progress.
When I want to display it, it is empty. Is there a way to display it to compare its 2 values (after the get and before the release)?when to call the function "onWebRTCCallChanged"?
$(document).on(rainbowSDK.webRTC.RAINBOW_ONWEBRTCCALLSTATECHANGED, onWebRTCCallChanged);
thank you for your helpMy code is simple (a call button and a hang up button), and it is not angular.
NAJI.
-
Sorry, bad copy/paste, can you move the
currentCall = call;
inside
case Call.Status.ACTIVE.value:
And I don't know in your code what is the "box" at the end of the "case" ("case" which are missing in your js code !)
See example there: https://hub.openrainbow.com/#/documentation/doc/sdk/web/guides/4-Make_audio_and_video_callwith:
/* Somewhere in your application... */ var onWebRTCCallChanged = function onWebRTCCallChanged(event, call) { /* Listen to WebRTC call state change */ switch(call.status.value) { case call.Status.RINGING_INCOMMING.value: /* Answer or reject the call */ rainbowSDK.webRTC.answerInVideo(call); break; case call.Status.ACTIVE.value: /* display the local and remote video */ rainbowSDK.webRTC.showLocalVideo(); rainbowSDK.webRTC.showRemoteVideo(call); break; case call.Status.UNKNOWN.value: /* Hiding the local and remote video */ rainbowSDK.webRTC.hideLocalVideo(); rainbowSDK.webRTC.hideRemoteVideo(call); break; default: break; } }
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
7 Kommentare