Upgrade to webex.meetings

webex.phone is no longer the default, though you can use it with SDK versions 1.6x or by creating a custom build.

webex.meetings delivers a better meeting (call) experience with tighter integrations across Webex products and devices. Follow our upgrade guide and look at our samples to include it in your application.


webex.phone

First, authenticate according to Browsers. From there, you’ll need to register with our cloud and start listening for incoming calls.

webex.phone.register();

Previous versions of this guide indicated you were responsible for caching your own registration data. As of ciscospark@0.7.0, this is handled automatically for you.

To place a call, use webex.phone.dial(). Don’t forget to connect the media streams to some video tags on your page.

Previous versions of this guide instructued you to use call.remoteMediaStreamUrl. Changes to the webrtc spec mean that you should now reference call.remoteMediaStream and call.localMediaStream directly.

var call = webex.phone.dial('alice@example.com');
call.on('connected', function() {
  document.getElementById('incoming-video').srcObject = call.remoteMediaStream;
});
call.on('localMediaStream:change', function() {
  document.getElementById('outgoing-video').srcObject = call.localMediaStream;
  // Mute the local video so you don't hear yourself speaking
  document.getElementById('outgoing-video').muted = true;
});

To handle an incoming call, listen for the call:incoming event

webex.phone.on('call:incoming', function(call) {
  // Set up listeners to update the UI if the callee chooses to answer the call.
  call.on('connected', function() {
    document.getElementById('incoming-video').srcObject = call.remoteMediaStream;
  });
  call.on('localMediaStream:change', function() {
    document.getElementById('outgoing-video').srcObject = call.localMediaStream;
    // Mute the local video so you don't hear yourself speaking
    document.getElementById('outgoing-video').muted = true;
  });

  // Let the caller know that you've indicated to the callee that there's an incoming call
  call.acknowledge();

  // Answer the call
  call.answer();
});