@stream-io/video-react-native-sdk 0.8.7 → 0.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/commonjs/components/Call/CallControls/ScreenShareToggleButton.js +6 -76
- package/dist/commonjs/components/Call/CallControls/ScreenShareToggleButton.js.map +1 -1
- package/dist/commonjs/components/Livestream/LivestreamControls/LivestreamScreenShareToggleButton.js +7 -69
- package/dist/commonjs/components/Livestream/LivestreamControls/LivestreamScreenShareToggleButton.js.map +1 -1
- package/dist/commonjs/components/Livestream/LivestreamPlayer/LivestreamPlayer.js +6 -5
- package/dist/commonjs/components/Livestream/LivestreamPlayer/LivestreamPlayer.js.map +1 -1
- package/dist/commonjs/hooks/index.js +11 -0
- package/dist/commonjs/hooks/index.js.map +1 -1
- package/dist/commonjs/hooks/useScreenShareButton.js +89 -0
- package/dist/commonjs/hooks/useScreenShareButton.js.map +1 -0
- package/dist/commonjs/version.js +1 -1
- package/dist/module/components/Call/CallControls/ScreenShareToggleButton.js +8 -78
- package/dist/module/components/Call/CallControls/ScreenShareToggleButton.js.map +1 -1
- package/dist/module/components/Livestream/LivestreamControls/LivestreamScreenShareToggleButton.js +7 -68
- package/dist/module/components/Livestream/LivestreamControls/LivestreamScreenShareToggleButton.js.map +1 -1
- package/dist/module/components/Livestream/LivestreamPlayer/LivestreamPlayer.js +3 -2
- package/dist/module/components/Livestream/LivestreamPlayer/LivestreamPlayer.js.map +1 -1
- package/dist/module/hooks/index.js +1 -0
- package/dist/module/hooks/index.js.map +1 -1
- package/dist/module/hooks/useScreenShareButton.js +83 -0
- package/dist/module/hooks/useScreenShareButton.js.map +1 -0
- package/dist/module/version.js +1 -1
- package/dist/typescript/components/Call/CallControls/ScreenShareToggleButton.d.ts.map +1 -1
- package/dist/typescript/components/Livestream/LivestreamControls/LivestreamScreenShareToggleButton.d.ts +1 -1
- package/dist/typescript/components/Livestream/LivestreamControls/LivestreamScreenShareToggleButton.d.ts.map +1 -1
- package/dist/typescript/components/Livestream/LivestreamPlayer/LivestreamPlayer.d.ts +1 -1
- package/dist/typescript/components/Livestream/LivestreamPlayer/LivestreamPlayer.d.ts.map +1 -1
- package/dist/typescript/hooks/index.d.ts +1 -0
- package/dist/typescript/hooks/index.d.ts.map +1 -1
- package/dist/typescript/hooks/useScreenShareButton.d.ts +9 -0
- package/dist/typescript/hooks/useScreenShareButton.d.ts.map +1 -0
- package/dist/typescript/version.d.ts +1 -1
- package/expo-config-plugin/dist/withAndroidManifest.js +6 -6
- package/expo-config-plugin/dist/withMainActivity.js +17 -0
- package/package.json +3 -3
- package/src/components/Call/CallControls/ScreenShareToggleButton.tsx +9 -95
- package/src/components/Livestream/LivestreamControls/LivestreamScreenShareToggleButton.tsx +6 -91
- package/src/components/Livestream/LivestreamPlayer/LivestreamPlayer.tsx +4 -3
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useScreenShareButton.ts +128 -0
- package/src/version.ts +1 -1
|
@@ -1,30 +1,13 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { useTheme } from '../../../contexts/ThemeContext';
|
|
3
|
-
import {
|
|
4
|
-
findNodeHandle,
|
|
5
|
-
NativeModules,
|
|
6
|
-
Platform,
|
|
7
|
-
Pressable,
|
|
8
|
-
StyleSheet,
|
|
9
|
-
View,
|
|
10
|
-
} from 'react-native';
|
|
3
|
+
import { Platform, Pressable, StyleSheet, View } from 'react-native';
|
|
11
4
|
import { ScreenShare } from '../../../icons/ScreenShare';
|
|
12
5
|
import { StopScreenShare } from '../../../icons/StopScreenShare';
|
|
13
6
|
import { ScreenCapturePickerView } from '@stream-io/react-native-webrtc';
|
|
14
|
-
import {
|
|
15
|
-
import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
|
|
16
|
-
import { useIsIosScreenshareBroadcastStarted } from '../../../hooks/useIsIosScreenshareBroadcastStarted';
|
|
17
|
-
import { usePrevious } from '../../../utils/hooks/usePrevious';
|
|
7
|
+
import { useScreenShareButton } from '../../../hooks/useScreenShareButton';
|
|
18
8
|
|
|
19
9
|
export type LivestreamScreenShareToggleButtonProps = {};
|
|
20
10
|
|
|
21
|
-
// ios >= 14.0 or android - platform restrictions
|
|
22
|
-
const CanDeviceScreenShare =
|
|
23
|
-
(Platform.OS === 'ios' &&
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
Number.parseInt(Platform.Version.split('.')[0], 10) >= 14) ||
|
|
26
|
-
Platform.OS === 'android';
|
|
27
|
-
|
|
28
11
|
/**
|
|
29
12
|
* The LivestreamVideoControlButton controls the screenshare stream publish/unpublish while in the livestream for the host.
|
|
30
13
|
*/
|
|
@@ -37,79 +20,11 @@ export const LivestreamScreenShareToggleButton = () => {
|
|
|
37
20
|
},
|
|
38
21
|
} = useTheme();
|
|
39
22
|
|
|
40
|
-
const call = useCall();
|
|
41
|
-
const { useLocalParticipant, useCallSettings } = useCallStateHooks();
|
|
42
|
-
const callSettings = useCallSettings();
|
|
43
|
-
const isScreenSharingEnabledInCall = callSettings?.screensharing.enabled;
|
|
44
|
-
|
|
45
|
-
const iosScreenShareStartedFromSystem = useIsIosScreenshareBroadcastStarted();
|
|
46
|
-
const prevIosScreenShareStartedFromSystem = usePrevious(
|
|
47
|
-
iosScreenShareStartedFromSystem
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
const localParticipant = useLocalParticipant();
|
|
51
|
-
const hasPublishedScreenShare =
|
|
52
|
-
localParticipant && hasScreenShare(localParticipant);
|
|
53
|
-
|
|
54
|
-
// listens to iOS screen share broadcast started event from the system
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
const run = async () => {
|
|
57
|
-
if (Platform.OS !== 'ios') {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
if (
|
|
61
|
-
iosScreenShareStartedFromSystem &&
|
|
62
|
-
!prevIosScreenShareStartedFromSystem
|
|
63
|
-
) {
|
|
64
|
-
const media = await navigator.mediaDevices.getDisplayMedia({
|
|
65
|
-
// @ts-ignore
|
|
66
|
-
deviceId: 'broadcast',
|
|
67
|
-
video: true,
|
|
68
|
-
audio: true,
|
|
69
|
-
});
|
|
70
|
-
await call?.publishScreenShareStream(media);
|
|
71
|
-
} else if (
|
|
72
|
-
!iosScreenShareStartedFromSystem &&
|
|
73
|
-
prevIosScreenShareStartedFromSystem
|
|
74
|
-
) {
|
|
75
|
-
await call?.stopPublish(SfuModels.TrackType.SCREEN_SHARE);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
run();
|
|
79
|
-
}, [
|
|
80
|
-
call,
|
|
81
|
-
iosScreenShareStartedFromSystem,
|
|
82
|
-
prevIosScreenShareStartedFromSystem,
|
|
83
|
-
]);
|
|
84
|
-
|
|
85
23
|
const screenCapturePickerViewiOSRef = React.useRef(null);
|
|
86
24
|
|
|
87
|
-
const onPress =
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const reactTag = findNodeHandle(screenCapturePickerViewiOSRef.current);
|
|
91
|
-
await NativeModules.ScreenCapturePickerViewManager.show(reactTag);
|
|
92
|
-
// After this the iOS screen share broadcast started/stopped event will be triggered
|
|
93
|
-
// and the useEffect listener will handle the rest
|
|
94
|
-
} else {
|
|
95
|
-
try {
|
|
96
|
-
const media = await navigator.mediaDevices.getDisplayMedia({
|
|
97
|
-
video: true,
|
|
98
|
-
audio: true,
|
|
99
|
-
});
|
|
100
|
-
await call?.publishScreenShareStream(media);
|
|
101
|
-
} catch (e) {
|
|
102
|
-
// ignored.. user didnt allow the screen share in the popup
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
} else if (hasPublishedScreenShare) {
|
|
106
|
-
await call?.stopPublish(SfuModels.TrackType.SCREEN_SHARE);
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
if (!isScreenSharingEnabledInCall || !CanDeviceScreenShare) {
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
25
|
+
const { onPress, hasPublishedScreenShare } = useScreenShareButton(
|
|
26
|
+
screenCapturePickerViewiOSRef
|
|
27
|
+
);
|
|
113
28
|
|
|
114
29
|
return (
|
|
115
30
|
<Pressable
|
|
@@ -2,9 +2,10 @@ import React, { useEffect, useState } from 'react';
|
|
|
2
2
|
import {
|
|
3
3
|
ViewerLivestream as DefaultViewerLivestream,
|
|
4
4
|
ViewerLivestreamProps,
|
|
5
|
-
} from '
|
|
6
|
-
import { Call,
|
|
7
|
-
import {
|
|
5
|
+
} from '../ViewerLivestream';
|
|
6
|
+
import { Call, CallingState, getLogger } from '@stream-io/video-client';
|
|
7
|
+
import { StreamCall } from '../../../providers/StreamCall';
|
|
8
|
+
import { useStreamVideoClient } from '@stream-io/video-react-bindings';
|
|
8
9
|
|
|
9
10
|
export type LivestreamPlayerProps = {
|
|
10
11
|
/**
|
package/src/hooks/index.ts
CHANGED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getLogger,
|
|
3
|
+
hasScreenShare,
|
|
4
|
+
OwnCapability,
|
|
5
|
+
} from '@stream-io/video-client';
|
|
6
|
+
import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
|
|
7
|
+
import React, { useRef, useEffect } from 'react';
|
|
8
|
+
import { Platform, findNodeHandle, NativeModules } from 'react-native';
|
|
9
|
+
import { usePrevious } from '../utils/hooks';
|
|
10
|
+
import { useIsIosScreenshareBroadcastStarted } from './useIsIosScreenshareBroadcastStarted';
|
|
11
|
+
|
|
12
|
+
// ios >= 14.0 or android - platform restrictions
|
|
13
|
+
const CanDeviceScreenShare =
|
|
14
|
+
(Platform.OS === 'ios' &&
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
Number.parseInt(Platform.Version.split('.')[0], 10) >= 14,
|
|
17
|
+
10) || Platform.OS === 'android';
|
|
18
|
+
|
|
19
|
+
export const useScreenShareButton = (
|
|
20
|
+
/**
|
|
21
|
+
* Ref of the ScreenCapturePickerView component.
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
screenCapturePickerViewiOSRef: React.MutableRefObject<any>,
|
|
25
|
+
/**
|
|
26
|
+
* Handler to be called when the screen-share has been started.
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
onScreenShareStartedHandler?: () => void,
|
|
30
|
+
/**
|
|
31
|
+
* Handler to be called when the screen-share has been stopped.
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
34
|
+
onScreenShareStoppedHandler?: () => void,
|
|
35
|
+
/**
|
|
36
|
+
* Handler to be called when the permissions to stream screen share media is missing
|
|
37
|
+
*
|
|
38
|
+
*/
|
|
39
|
+
onMissingScreenShareStreamPermission?: () => void
|
|
40
|
+
) => {
|
|
41
|
+
const call = useCall();
|
|
42
|
+
const { useLocalParticipant, useCallSettings, useOwnCapabilities } =
|
|
43
|
+
useCallStateHooks();
|
|
44
|
+
const callSettings = useCallSettings();
|
|
45
|
+
const ownCapabilities = useOwnCapabilities();
|
|
46
|
+
const hasScreenSharingPermissions = ownCapabilities?.includes(
|
|
47
|
+
OwnCapability.SCREENSHARE
|
|
48
|
+
);
|
|
49
|
+
const isScreenSharingEnabledInCall = callSettings?.screensharing.enabled;
|
|
50
|
+
|
|
51
|
+
const onScreenShareStartedHandlerRef = useRef(onScreenShareStartedHandler);
|
|
52
|
+
onScreenShareStartedHandlerRef.current = onScreenShareStartedHandler;
|
|
53
|
+
const onScreenShareStoppedHandlerRef = useRef(onScreenShareStoppedHandler);
|
|
54
|
+
onScreenShareStoppedHandlerRef.current = onScreenShareStoppedHandler;
|
|
55
|
+
|
|
56
|
+
const iosScreenShareStartedFromSystem = useIsIosScreenshareBroadcastStarted();
|
|
57
|
+
const prevIosScreenShareStartedFromSystem = usePrevious(
|
|
58
|
+
iosScreenShareStartedFromSystem
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const localParticipant = useLocalParticipant();
|
|
62
|
+
const hasPublishedScreenShare =
|
|
63
|
+
localParticipant && hasScreenShare(localParticipant);
|
|
64
|
+
|
|
65
|
+
// listens to iOS screen share broadcast started event from the system
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (Platform.OS !== 'ios') {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (
|
|
71
|
+
iosScreenShareStartedFromSystem &&
|
|
72
|
+
!prevIosScreenShareStartedFromSystem
|
|
73
|
+
) {
|
|
74
|
+
onScreenShareStartedHandlerRef.current?.();
|
|
75
|
+
call?.screenShare.enable();
|
|
76
|
+
} else if (
|
|
77
|
+
!iosScreenShareStartedFromSystem &&
|
|
78
|
+
prevIosScreenShareStartedFromSystem
|
|
79
|
+
) {
|
|
80
|
+
onScreenShareStoppedHandlerRef.current?.();
|
|
81
|
+
call?.screenShare.disable(true);
|
|
82
|
+
}
|
|
83
|
+
}, [
|
|
84
|
+
call,
|
|
85
|
+
iosScreenShareStartedFromSystem,
|
|
86
|
+
prevIosScreenShareStartedFromSystem,
|
|
87
|
+
]);
|
|
88
|
+
|
|
89
|
+
const onPress = async () => {
|
|
90
|
+
if (!hasScreenSharingPermissions) {
|
|
91
|
+
const logger = getLogger(['useScreenShareButton']);
|
|
92
|
+
logger(
|
|
93
|
+
'info',
|
|
94
|
+
'User does not have permissions to stream the screen share media, calling onMissingScreenShareStreamPermission handler if present'
|
|
95
|
+
);
|
|
96
|
+
onMissingScreenShareStreamPermission?.();
|
|
97
|
+
}
|
|
98
|
+
if (!hasPublishedScreenShare) {
|
|
99
|
+
if (Platform.OS === 'ios') {
|
|
100
|
+
const reactTag = findNodeHandle(screenCapturePickerViewiOSRef.current);
|
|
101
|
+
await NativeModules.ScreenCapturePickerViewManager.show(reactTag);
|
|
102
|
+
// After this the iOS screen share broadcast started/stopped event will be triggered
|
|
103
|
+
// and the useEffect listener will handle the rest
|
|
104
|
+
} else {
|
|
105
|
+
try {
|
|
106
|
+
await call?.screenShare.enable();
|
|
107
|
+
onScreenShareStartedHandler?.();
|
|
108
|
+
} catch (error) {
|
|
109
|
+
// ignored.. user didnt allow the screen share in the popup
|
|
110
|
+
const logger = getLogger(['useScreenShareButton']);
|
|
111
|
+
logger(
|
|
112
|
+
'info',
|
|
113
|
+
'User opted to not give permissions to start a screen share stream',
|
|
114
|
+
error
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
} else if (hasPublishedScreenShare) {
|
|
119
|
+
onScreenShareStoppedHandler?.();
|
|
120
|
+
await call?.screenShare.disable(true);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
if (!isScreenSharingEnabledInCall || !CanDeviceScreenShare) {
|
|
125
|
+
return { onPress: undefined, hasPublishedScreenShare: false };
|
|
126
|
+
}
|
|
127
|
+
return { onPress, hasPublishedScreenShare };
|
|
128
|
+
};
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '0.8.
|
|
1
|
+
export const version = '0.8.8';
|