Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions example/src/ParticipantView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export const ParticipantView = forwardRef<Component, Props>(
enabled: useIOSPIP,
startAutomatically: true,
preferredSize: {
width: 800,
height: 800,
width: 1,
height: 1,
},
}}
/>
Expand Down
19 changes: 13 additions & 6 deletions src/components/VideoTrack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,14 @@ export type VideoTrackProps = {
*
* iOS only. Requires iOS 15.0 or above, and the PIP background mode capability.
*
* If `iosPIP.enabled` is true, startIOSPIP and stopIOSPIP can be used to manually
* trigger the PIP mode. `iosPIP.startAutomatically` can be used to automatically
* If `iosPIP.enabled` is true, the methods `startIOSPIP` and `stopIOSPIP`
* can be used to manually trigger the PIP mode.
*
* `iosPIP.startAutomatically` can be used to automatically
* enter PIP when backgrounding the app.
*
* `iosPIP.preferredSize` is used to provide a suggested aspect ratio.
*
* @example
* ```tsx
* import { startIOSPIP, stopIOSPIP } from '@livekit/react-native-webrtc';
Expand All @@ -98,8 +102,8 @@ export type VideoTrackProps = {
* enabled: true,
* startAutomatically: true,
* preferredSize: {
* width: 800,
* height: 800,
* width: 9,
* height: 16,
* },
* }}
* ...
Expand Down Expand Up @@ -151,9 +155,12 @@ export const VideoTrack = forwardRef<Component, VideoTrackProps>(
(event: LayoutChangeEvent) => elementInfo.onLayout(event),
[elementInfo]
);

const iosPIPEnabled = iosPIP?.enabled ?? false;
const visibilityOnChange = useCallback(
(isVisible: boolean) => elementInfo.onVisibility(isVisible),
[elementInfo]
(isVisible: boolean) =>
elementInfo.onVisibility(isVisible || iosPIPEnabled),
[elementInfo, iosPIPEnabled]
);

const videoTrack = trackRef?.publication.track;
Expand Down