Skip to content

Commit ac469a4

Browse files
authored
fix: consider remote video track as visible when ios PIP is enabled (#233)
1 parent 3f7bae3 commit ac469a4

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

example/src/ParticipantView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ export const ParticipantView = forwardRef<Component, Props>(
4444
enabled: useIOSPIP,
4545
startAutomatically: true,
4646
preferredSize: {
47-
width: 800,
48-
height: 800,
47+
width: 1,
48+
height: 1,
4949
},
5050
}}
5151
/>

src/components/VideoTrack.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,14 @@ export type VideoTrackProps = {
8181
*
8282
* iOS only. Requires iOS 15.0 or above, and the PIP background mode capability.
8383
*
84-
* If `iosPIP.enabled` is true, startIOSPIP and stopIOSPIP can be used to manually
85-
* trigger the PIP mode. `iosPIP.startAutomatically` can be used to automatically
84+
* If `iosPIP.enabled` is true, the methods `startIOSPIP` and `stopIOSPIP`
85+
* can be used to manually trigger the PIP mode.
86+
*
87+
* `iosPIP.startAutomatically` can be used to automatically
8688
* enter PIP when backgrounding the app.
8789
*
90+
* `iosPIP.preferredSize` is used to provide a suggested aspect ratio.
91+
*
8892
* @example
8993
* ```tsx
9094
* import { startIOSPIP, stopIOSPIP } from '@livekit/react-native-webrtc';
@@ -98,8 +102,8 @@ export type VideoTrackProps = {
98102
* enabled: true,
99103
* startAutomatically: true,
100104
* preferredSize: {
101-
* width: 800,
102-
* height: 800,
105+
* width: 9,
106+
* height: 16,
103107
* },
104108
* }}
105109
* ...
@@ -151,9 +155,12 @@ export const VideoTrack = forwardRef<Component, VideoTrackProps>(
151155
(event: LayoutChangeEvent) => elementInfo.onLayout(event),
152156
[elementInfo]
153157
);
158+
159+
const iosPIPEnabled = iosPIP?.enabled ?? false;
154160
const visibilityOnChange = useCallback(
155-
(isVisible: boolean) => elementInfo.onVisibility(isVisible),
156-
[elementInfo]
161+
(isVisible: boolean) =>
162+
elementInfo.onVisibility(isVisible || iosPIPEnabled),
163+
[elementInfo, iosPIPEnabled]
157164
);
158165

159166
const videoTrack = trackRef?.publication.track;

0 commit comments

Comments
 (0)