stream-chat-expo 7.2.9 → 7.3.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stream-chat-expo",
3
3
  "description": "The official Expo SDK for Stream Chat, a service for building chat applications",
4
- "version": "7.2.9",
4
+ "version": "7.3.0",
5
5
  "author": {
6
6
  "company": "Stream.io Inc",
7
7
  "name": "Stream.io Inc"
@@ -11,7 +11,7 @@
11
11
  "types": "types/index.d.ts",
12
12
  "dependencies": {
13
13
  "mime": "^4.0.7",
14
- "stream-chat-react-native-core": "7.2.9"
14
+ "stream-chat-react-native-core": "7.3.0"
15
15
  },
16
16
  "peerDependencies": {
17
17
  "expo": ">=51.0.0",
@@ -1,17 +1,20 @@
1
1
  let AudioComponent;
2
+ let VideoComponent;
2
3
  let RecordingObject;
4
+
3
5
  try {
4
6
  const audioVideoPackage = require('expo-av');
5
7
  AudioComponent = audioVideoPackage.Audio;
8
+ VideoComponent = audioVideoPackage.Video;
6
9
  RecordingObject = audioVideoPackage.RecordingObject;
7
10
  } catch (e) {
8
11
  // do nothing
9
12
  }
10
13
 
11
- if (!AudioComponent) {
14
+ if (!AudioComponent || !VideoComponent) {
12
15
  console.log(
13
16
  'Audio Video library is currently not installed. To allow in-app audio playback, install the "expo-av" package.',
14
17
  );
15
18
  }
16
19
 
17
- export { AudioComponent, RecordingObject };
20
+ export { AudioComponent, RecordingObject, VideoComponent };
@@ -2,7 +2,7 @@ import React, { useEffect } from 'react';
2
2
 
3
3
  import { useEventListener } from 'expo';
4
4
 
5
- import { AudioComponent } from './AudioVideo';
5
+ import { AudioComponent, VideoComponent as ExpoAVVideoComponent } from './AudioVideo';
6
6
 
7
7
  let videoPackage;
8
8
 
@@ -18,56 +18,98 @@ if (!videoPackage) {
18
18
  );
19
19
  }
20
20
 
21
- const VideoComponent = videoPackage ? videoPackage.VideoView : null;
21
+ const VideoComponent = videoPackage ? videoPackage.VideoView : ExpoAVVideoComponent;
22
22
  const useVideoPlayer = videoPackage ? videoPackage.useVideoPlayer : null;
23
23
 
24
- export const Video = videoPackage
25
- ? ({ onLoadStart, onLoad, onEnd, onProgress, onBuffer, resizeMode, style, uri, videoRef }) => {
26
- const player = useVideoPlayer(uri, (player) => {
27
- player.timeUpdateEventInterval = 0.5;
28
- videoRef.current = player;
29
- });
24
+ let Video = null;
30
25
 
31
- useEventListener(player, 'statusChange', ({ status, oldStatus }) => {
32
- if ((!oldStatus || oldStatus === 'idle') && status === 'loading') {
33
- onLoadStart();
34
- } else if ((oldStatus === 'loading' || oldStatus === 'idle') && status === 'readyToPlay') {
35
- onLoad({ duration: player.duration });
36
- onBuffer({ buffering: false });
37
- } else if (oldStatus === 'readyToPlay' && status === 'loading') {
38
- onBuffer({ buffering: true });
39
- }
40
- });
26
+ // expo-video
27
+ if (videoPackage) {
28
+ Video = ({
29
+ onLoadStart,
30
+ onLoad,
31
+ onEnd,
32
+ onProgress,
33
+ onBuffer,
34
+ resizeMode,
35
+ style,
36
+ uri,
37
+ videoRef,
38
+ }) => {
39
+ const player = useVideoPlayer(uri, (player) => {
40
+ player.timeUpdateEventInterval = 0.5;
41
+ videoRef.current = player;
42
+ });
43
+
44
+ useEventListener(player, 'statusChange', ({ status, oldStatus }) => {
45
+ if ((!oldStatus || oldStatus === 'idle') && status === 'loading') {
46
+ onLoadStart();
47
+ } else if ((oldStatus === 'loading' || oldStatus === 'idle') && status === 'readyToPlay') {
48
+ onLoad({ duration: player.duration });
49
+ onBuffer({ buffering: false });
50
+ } else if (oldStatus === 'readyToPlay' && status === 'loading') {
51
+ onBuffer({ buffering: true });
52
+ }
53
+ });
41
54
 
42
- useEventListener(player, 'playToEnd', () => {
43
- player.replay();
44
- onEnd();
45
- });
55
+ useEventListener(player, 'playToEnd', () => {
56
+ player.replay();
57
+ onEnd();
58
+ });
46
59
 
47
- useEventListener(player, 'timeUpdate', ({ currentTime }) =>
48
- onProgress({ currentTime, seekableDuration: player.duration }),
49
- );
60
+ useEventListener(player, 'timeUpdate', ({ currentTime }) =>
61
+ onProgress({ currentTime, seekableDuration: player.duration }),
62
+ );
63
+
64
+ // This is done so that the audio of the video is not muted when the phone is in silent mode for iOS.
65
+ useEffect(() => {
66
+ const initializeSound = async () => {
67
+ if (AudioComponent) {
68
+ await AudioComponent.setAudioModeAsync({
69
+ playsInSilentModeIOS: true,
70
+ });
71
+ }
72
+ };
73
+ initializeSound();
74
+ }, []);
50
75
 
51
- // This is done so that the audio of the video is not muted when the phone is in silent mode for iOS.
52
- useEffect(() => {
53
- const initializeSound = async () => {
54
- if (AudioComponent) {
55
- await AudioComponent.setAudioModeAsync({
56
- playsInSilentModeIOS: true,
57
- });
58
- }
59
- };
60
- initializeSound();
61
- }, []);
76
+ return (
77
+ <VideoComponent
78
+ allowsFullscreen
79
+ contentFit={resizeMode}
80
+ nativeControls={false}
81
+ player={player}
82
+ style={[style]}
83
+ />
84
+ );
85
+ };
86
+ }
87
+ // expo-av
88
+ else if (ExpoAVVideoComponent) {
89
+ Video = ({ onPlaybackStatusUpdate, paused, resizeMode, style, uri, videoRef }) => {
90
+ // This is done so that the audio of the video is not muted when the phone is in silent mode for iOS.
91
+ useEffect(() => {
92
+ const initializeSound = async () => {
93
+ await AudioComponent.setAudioModeAsync({
94
+ playsInSilentModeIOS: true,
95
+ });
96
+ };
97
+ initializeSound();
98
+ }, []);
99
+
100
+ return (
101
+ <VideoComponent
102
+ onPlaybackStatusUpdate={onPlaybackStatusUpdate}
103
+ ref={videoRef}
104
+ resizeMode={resizeMode}
105
+ shouldPlay={!paused}
106
+ source={{
107
+ uri,
108
+ }}
109
+ style={[style]}
110
+ />
111
+ );
112
+ };
113
+ }
62
114
 
63
- return (
64
- <VideoComponent
65
- allowsFullscreen
66
- contentFit={resizeMode}
67
- nativeControls={false}
68
- player={player}
69
- style={[style]}
70
- />
71
- );
72
- }
73
- : null;
115
+ export { Video };