Call​Control Call​Control Call​Control Call​Control Class

Definition

Represents the properties, commands and events for handling calls on a telephony related device.

public : sealed class CallControl : ICallControlpublic sealed class CallControl : ICallControlPublic NotInheritable Class CallControl Implements ICallControl// You can use this class in JavaScript.
Attributes
Windows 10 requirements
Device family
Windows Desktop Extension SDK (introduced v10.0.10240.0)
API contract
Windows.Media.Devices.CallControlContract (introduced v1)

Remarks

This class provides access to events that can be monitored and used for modifying the behavior of your telephony-aware app. The following JavaScript code snippet shows how to add event listeners to the CallControl class, and then to respond to one of the events, AnswerRequested.

// Define the user-defined valriables
var callControls = null;
var audioTag;

// Add code to initialize your user-defined variables as needed
<code goes here>

// Initialize the telephony device
    function initDevice() {
        if (!callControls) {
            try {
                callControls = Windows.Media.Devices.CallControl.getDefault();

                if (callControls) {
                    // Add the event listener to listen for the various button presses
                    callControls.addEventListener("answerrequested", answerButton, false);
                    callControls.addEventListener("hanguprequested", hangupButton, false);
                    callControls.addEventListener("audiotransferrequested", audiotransferButton, false);
                    callControls.addEventListener("redialrequested", redialButton, false);
                    callControls.addEventListener("dialrequested", dialButton, false);

                    sdkSample.displayStatus("Call Controls Initialized");
                    id("scenario1Ring").disabled = false;
                } else {
                    sdkSample.displayError("No Bluetooth device detected.");
                }
            }
            catch (e) {                
                sdkSample.displayError("No Bluetooth device detected.");
            }
        }

// Event handler code to respond to the AnswerRequested event
    function answerButton() {
        // When the answer button is pressed indicate to the device that the call was answered
        // and start a song on the headset (this is done by streaming music to the bluetooth
        // device in this sample)
        sdkSample.displayStatus("Answer requested: " + callToken);
        callControls.indicateActiveCall(callToken);
        audiotag = document.getElementById("audiotag");
        audiotag.play();
    }

For the complete listing of this sample see How to manage calls on the default Bluetooth communications device.

Properties

HasRinger HasRinger HasRinger HasRinger

Indicates whether the telephony device has a built-in ringer.

public : PlatForm::Boolean HasRinger { get; }public bool HasRinger { get; }Public ReadOnly Property HasRinger As bool// You can use this property in JavaScript.
Value
PlatForm::Boolean bool bool bool

A Boolean value that is True if the telephony device has a ringer, and False if it does not.

Methods

EndCall(UInt64) EndCall(UInt64) EndCall(UInt64) EndCall(UInt64)

Ends the specified call.

public : void EndCall(unsigned __int64 callToken)public void EndCall(UInt64 callToken)Public Function EndCall(callToken As UInt64) As void// You can use this method in JavaScript.
Parameters
callToken
unsigned __int64 UInt64 UInt64 UInt64

The unique identifier of the specified call.

Remarks

After this method is called, the callToken of the specified call is no longer valid.

FromId(String) FromId(String) FromId(String) FromId(String)

Returns a CallControl class that represents the audio communications device specified by the DeviceInformation ID being passed.

public : static CallControl FromId(PlatForm::String deviceId)public static CallControl FromId(String deviceId)Public Static Function FromId(deviceId As String) As CallControl// You can use this method in JavaScript.
Parameters
deviceId
PlatForm::String String String String

The DeviceInformation ID of the specified audio communications device.

Returns

A class that represents the specified audio communications device.

Remarks

This method may return a NULL pointer if the device doesn't support this functionality.

GetDefault() GetDefault() GetDefault() GetDefault()

Returns a CallControl class that represents the default audio communications device.

public : static CallControl GetDefault()public static CallControl GetDefault()Public Static Function GetDefault() As CallControl// You can use this method in JavaScript.
Returns

A class that represents the default audio communications device.

Remarks

This method may return a NULL pointer if the device doesn't support this functionality.

IndicateActiveCall(UInt64) IndicateActiveCall(UInt64) IndicateActiveCall(UInt64) IndicateActiveCall(UInt64)

Indicates that the specified call is now active.

public : void IndicateActiveCall(unsigned __int64 callToken)public void IndicateActiveCall(UInt64 callToken)Public Function IndicateActiveCall(callToken As UInt64) As void// You can use this method in JavaScript.
Parameters
callToken
unsigned __int64 UInt64 UInt64 UInt64

The unique identifier of the specified call.

IndicateNewIncomingCall(Boolean, String) IndicateNewIncomingCall(Boolean, String) IndicateNewIncomingCall(Boolean, String) IndicateNewIncomingCall(Boolean, String)

Informs the device that there is an incoming call.

public : ulong IndicateNewIncomingCall(bool enableRinger, PlatForm::String callerId)public ulong IndicateNewIncomingCall(Boolean enableRinger, String callerId)Public Function IndicateNewIncomingCall(enableRinger As Boolean, callerId As String) As ulong// You can use this method in JavaScript.
Parameters
enableRinger
bool Boolean Boolean Boolean

Specifies whether the device should activate its built-in ringer.

callerId
PlatForm::String String String String

A numeric string that specifies the incoming caller ID. This parameter can be null, and often is for many VoIP calls.

Returns
ulong ulong ulong ulong

A call token that uniquely identifies this call.

IndicateNewOutgoingCall() IndicateNewOutgoingCall() IndicateNewOutgoingCall() IndicateNewOutgoingCall()

Updates device indicators to indicate an outgoing call.

public : ulong IndicateNewOutgoingCall()public ulong IndicateNewOutgoingCall()Public Function IndicateNewOutgoingCall() As ulong// You can use this method in JavaScript.
Returns
ulong ulong ulong ulong

A call token that uniquely identifies this call.

Remarks

An application should call this method only after the dialing connection is actually initiated, and not before.

Events

AnswerRequested AnswerRequested AnswerRequested AnswerRequested

Occurs when the device receives a request to answer a call.

public : event CallControlEventHandler AnswerRequestedpublic event CallControlEventHandler AnswerRequestedPublic Event AnswerRequested// You can use this event in JavaScript.

Remarks

This class provides access to events that can be monitored and used for modifying the behavior of your telephony-aware app. The following JavaScript code snippet shows how to add event listeners to the CallControl class, and then to respond to one of the events, AnswerRequested.

See Also

AudioTransferRequested AudioTransferRequested AudioTransferRequested AudioTransferRequested

Occurs when the device receives a request for an audio transfer.

public : event CallControlEventHandler AudioTransferRequestedpublic event CallControlEventHandler AudioTransferRequestedPublic Event AudioTransferRequested// You can use this event in JavaScript.

Remarks

This class provides access to events that can be monitored and used for modifying the behavior of your telephony-aware app. The following JavaScript code snippet shows how to add event listeners to the CallControl class, and then to respond to one of the events, AudioTransferRequested.

See Also

DialRequested DialRequested DialRequested DialRequested

Occurs when a number is dialed from the device.

public : event DialRequestedEventHandler DialRequestedpublic event DialRequestedEventHandler DialRequestedPublic Event DialRequested// You can use this event in JavaScript.

Remarks

This class provides access to events that can be monitored and used for modifying the behavior of your telephony-aware app. The following JavaScript code snippet shows how to add event listeners to the CallControl class, and then to respond to one of the events, DialRequested.

See Also

HangUpRequested HangUpRequested HangUpRequested HangUpRequested

Occurs when the device receives a request to hang up a call.

public : event CallControlEventHandler HangUpRequestedpublic event CallControlEventHandler HangUpRequestedPublic Event HangUpRequested// You can use this event in JavaScript.

Remarks

This class provides access to events that can be monitored and used for modifying the behavior of your telephony-aware app. The following JavaScript code snippet shows how to add event listeners to the CallControl class, and then to respond to one of the events, HangUpRequested.

KeypadPressed KeypadPressed KeypadPressed KeypadPressed

Occurs when a keypad button on the device has been pressed.

public : event KeypadPressedEventHandler KeypadPressedpublic event KeypadPressedEventHandler KeypadPressedPublic Event KeypadPressed// You can use this event in JavaScript.

RedialRequested RedialRequested RedialRequested RedialRequested

Occurs when the device receives a request to redial.

public : event RedialRequestedEventHandler RedialRequestedpublic event RedialRequestedEventHandler RedialRequestedPublic Event RedialRequested// You can use this event in JavaScript.

Remarks

This class provides access to events that can be monitored and used for modifying the behavior of your telephony-aware app. The following JavaScript code snippet shows how to add event listeners to the CallControl class, and then to respond to one of the events, RedialRequested.

See Also

See Also