in app/src/main/java/com/amazonaws/ivs/basicbroadcast/viewModel/MixerViewModel.kt [187:212]
fun swapSlots() {
Log.d(TAG, "Swapping the camera and content slots")
session?.let {
// Update slot configurations to their new state.
cameraIsSmall.apply {
cameraSlot?.let { slot ->
slot.position = if (cameraIsSmall) bigPosition else smallPositionBottomLeft
slot.size = if (cameraIsSmall) bigSize else smallSize
slot.setzIndex(if (cameraIsSmall) 1 else 2)
}
contentSlot?.let { slot ->
slot.position = if (cameraIsSmall) smallPositionTopRight else bigPosition
slot.size = if (cameraIsSmall) smallSize else bigSize
slot.setzIndex(if (cameraIsSmall) 2 else 1)
}
cameraIsSmall = !this
}
// Transition the slots to their new states over a 0.5 duration.
// Two common sources of failure is when the slot does not exist,
// or the new configuration slot name does not match the slot name provided to the method.
it.mixer?.transition(CAMERA_SLOT_NAME, cameraSlot!!, 0.5, null)
it.mixer?.transition(CONTENT_SLOT_NAME, contentSlot!!, 0.5, null)
}
}