await call.focus(focusPoint: point);
Long Press to Focus
Allowing users to manually focus the camera on specific areas is an important feature for video applications. The StreamVideo SDK makes this easy by handling all interactions with the device’s camera for you.
Basic Usage
To focus the camera on a specific point, simply call the focus
method on the Call
instance and provide the desired focusPoint
:
The focusPoint
parameter accepts a Point<double>
object that represents the normalized coordinates where:
- X and Y values range from 0.0 to 1.0
- (0.0, 0.0) represents the top-left corner
- (1.0, 1.0) represents the bottom-right corner
Example Implementation
The following example demonstrates how to implement a tap gesture to focus the camera on the tapped location:
StreamCallContainer(
call: widget.call,
callContentBuilder: (
BuildContext context,
Call call,
CallState callState,
) {
return StreamCallContent(
call: call,
callState: callState,
callParticipantsBuilder: (context, call, callState) {
return StreamCallParticipants(
call: call,
participants: callState.callParticipants,
localVideoParticipantBuilder: (context, call, participant) {
return LayoutBuilder(
builder: (context, constraints) {
return GestureDetector(
onTapDown: (TapDownDetails details) {
final point = Point<double>(
details.localPosition.dx / constraints.maxWidth,
details.localPosition.dy / constraints.maxHeight,
);
widget.call.focus(focusPoint: point);
},
child: StreamCallParticipant(
key: Key(participant.uniqueParticipantKey),
call: call,
participant: participant,
),
);
},
);
},
);
},
);
},
)
Platform Support
Camera focus functionality is available on both iOS and Android platforms. The behavior and support may vary depending on the device’s camera capabilities.
On this page: