| java.lang.Object | |
| ↳ | com.glia.androidsdk.comms.MediaUpgradeOffer |
Object that represents media upgrade request that is send by the Operator to the Visitor.
Used as part of Media.Events.
Usage example:
int micPermissionCode = 101;
int cameraPermissionCode = 102;
Consumer actionCallback = exception -> {
if (exception != null) {
// action not successful, something went wrong
} else {
// action was done successfully
}
};
Consumer handleMediaUpgradeOffer = mediaUpgradeOffer -> {
runOnUiThread(() -> {
if (mediaUpgradeOffer.audio != MediaDirection.TWO_WAY
&& mediaUpgradeOffer.video != MediaDirection.TWO_WAY) {
// notify Visitor about voice and/or video communication from Operator
mediaUpgradeOffer.accept(this, micPermissionCode, cameraPermissionCode, actionCallback);
} else {
// request User for his consent to send his microphone and/or camera input to Operator
// and call `accept` or `decline` based on his response.
}
});
};
engagement.getMedia().on(Media.Events.MEDIA_UPGRADE_OFFER, handleMediaUpgradeOffer);
| Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| public final MediaDirection | audio | Defines the required by Operator audio media state for this request. | |||||||||
| public final MediaDirection | video | Defines the required by Operator video media state for this request. | |||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| abstract void |
accept(Consumer<GliaException> callback)
Accepts media upgrade offer. | ||||||||||
| abstract void |
decline(Consumer<GliaException> callback)
Declines the media upgrade offer.
| ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
Defines the required by Operator audio media state for this request. See MediaDirection for possible options
Defines the required by Operator video media state for this request. See MediaDirection for possible options
Accepts media upgrade offer. Audio and video communication is started immediately after the permissions are given.
This method requires a unique request codes that can be used to trigger a microphone and camera permission
prompt via Activity#requestPermissions(String[], int).
See setRequestCode(int)
Make sure to call Engagement#onRequestPermissionsResult(int, String[], int[]) from the provided activity's Activity#onRequestPermissionsResult(int, String[], int[]) to allow Glia SDK to consume camera and microphone permission prompt result.
| callback | Called with null if done successfully or with GliaException if failed.
Exception may have one of following causes:
INTERNAL_ERROR - when internal error occurs
INVALID_INPUT - when activity is null for a two way request and required permissions are missing
PERMISSIONS_DENIED - when user declined required permission
NETWORK_TIMEOUT - when request times out due to connection issues |
|---|
Declines the media upgrade offer.
| callback | Called with null if done successfully or with GliaException if failed.
Exception may have one of following causes:
INTERNAL_ERROR - when internal error occurs
|
|---|