@cometchat/chat-uikit-react-native 4.2.2 → 4.3.1
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/README.md +26 -67
- package/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +2 -1
- package/android/src/main/java/com/reactnativecometchatuikit/ReactVideoView.java +796 -0
- package/android/src/main/java/com/reactnativecometchatuikit/ReactVideoViewManager.java +172 -0
- package/android/src/main/java/com/scalablevideoview/BuildConfig.java +10 -0
- package/android/src/main/java/com/scalablevideoview/PivotPoint.java +13 -0
- package/android/src/main/java/com/scalablevideoview/ScalableType.java +34 -0
- package/android/src/main/java/com/scalablevideoview/ScalableVideoView.java +255 -0
- package/android/src/main/java/com/scalablevideoview/ScaleManager.java +188 -0
- package/android/src/main/java/com/scalablevideoview/Size.java +20 -0
- package/android/src/main/java/com/zipfile/APEZProvider.java +287 -0
- package/android/src/main/java/com/zipfile/APKExpansionSupport.java +81 -0
- package/android/src/main/java/com/zipfile/ZipResourceFile.java +428 -0
- package/android/src/main/res/values/attrs.xml +37 -0
- package/ios/FileManager.m +75 -5
- package/ios/Video/CCRCTVideo.h +67 -0
- package/ios/Video/CCRCTVideo.m +2031 -0
- package/ios/Video/CCRCTVideoManager.h +6 -0
- package/ios/Video/CCRCTVideoManager.m +133 -0
- package/ios/Video/CCRCTVideoPlayerViewController.h +20 -0
- package/ios/Video/CCRCTVideoPlayerViewController.m +43 -0
- package/ios/Video/CCRCTVideoPlayerViewControllerDelegate.h +7 -0
- package/ios/Video/UIView+FindUIViewController.h +15 -0
- package/ios/Video/UIView+FindUIViewController.m +21 -0
- package/ios/VideoCaching/RCTVideoCache.h +38 -0
- package/ios/VideoCaching/RCTVideoCache.m +174 -0
- package/ios/VideoPickerModule.h +7 -0
- package/ios/VideoPickerModule.mm +95 -0
- package/package.json +3 -4
- package/react-native-cometchat-ui-kit.podspec +24 -10
- package/src/CometChatContacts/CometChatContacts.tsx +12 -9
- package/src/CometChatConversations/CometChatConversations.tsx +84 -64
- package/src/CometChatDetails/CometChatDetails.tsx +14 -12
- package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +8 -4
- package/src/CometChatGroupMembers/resources/check.png +0 -0
- package/src/CometChatGroupMembers/resources/index.ts +2 -0
- package/src/CometChatGroups/CometChatGroups.tsx +4 -4
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +57 -15
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +9 -2
- package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +1 -1
- package/src/CometChatMessageList/CometChatMessageList.tsx +596 -181
- package/src/CometChatMessageList/MessageListConfiguration.ts +55 -4
- package/src/CometChatMessageList/resources/index.ts +5 -1
- package/src/CometChatMessageList/resources/leftarrowcurve.png +0 -0
- package/src/CometChatMessageList/resources/rightarrowcurve.png +0 -0
- package/src/CometChatMessages/CometChatMessages.tsx +1 -1
- package/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx +4 -12
- package/src/CometChatThreadedMessages/style.ts +3 -1
- package/src/CometChatUsers/CometChatUsers.tsx +1 -1
- package/src/calls/CallUtils.ts +4 -8
- package/src/calls/CallingExtentionDecorator.tsx +5 -2
- package/src/calls/CometChatCallBubble/styles.ts +2 -1
- package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +14 -3
- package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +9 -9
- package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +80 -73
- package/src/extensions/CollaborativeBubble/styles.ts +2 -0
- package/src/extensions/SmartReplies/SmartRepliesDecorator.tsx +11 -0
- package/src/extensions/index.ts +0 -4
- package/src/index.ts +53 -8
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +14 -2
- package/src/shared/constants/UIKitConstants.ts +1 -0
- package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +6 -0
- package/src/shared/events/CometChatUIEventHandler/Listener.ts +8 -0
- package/src/shared/events/ListenerInitializer.ts +6 -0
- package/src/shared/events/messages.ts +2 -0
- package/src/shared/framework/MessageDataSource.tsx +29 -25
- package/src/shared/index.ts +49 -1
- package/src/shared/libs/VideoPlayer/DRMType.js +6 -0
- package/src/shared/libs/VideoPlayer/FilterType.js +18 -0
- package/src/shared/libs/VideoPlayer/TextTrackType.js +5 -0
- package/src/shared/libs/VideoPlayer/Video.js +519 -0
- package/src/shared/libs/VideoPlayer/VideoResizeMode.js +5 -0
- package/src/shared/libs/VideoPlayerControls/OSSupport/PlatformSupport.tsx +43 -0
- package/src/shared/libs/VideoPlayerControls/OSSupport/TVOSSupport.tsx +16 -0
- package/src/shared/libs/VideoPlayerControls/OSSupport/index.tsx +1 -0
- package/src/shared/libs/VideoPlayerControls/VideoPlayer.tsx +511 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/back.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/back@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/back@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/bottom-vignette.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/bottom-vignette@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/bottom-vignette@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/error-icon.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/error-icon@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/error-icon@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/expand.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/expand@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/expand@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/forward.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/forward@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/forward@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/loader-icon.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/loader-icon@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/loader-icon@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/pause.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/pause@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/pause@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/play.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/play@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/play@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/rewind.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/rewind@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/rewind@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/shrink.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/shrink@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/shrink@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/top-vignette.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/top-vignette@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/top-vignette@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/volume.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/volume@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/volume@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/components/Back/Back.tsx +28 -0
- package/src/shared/libs/VideoPlayerControls/components/Back/index.ts +1 -0
- package/src/shared/libs/VideoPlayerControls/components/BottomControls.tsx +142 -0
- package/src/shared/libs/VideoPlayerControls/components/Control.tsx +45 -0
- package/src/shared/libs/VideoPlayerControls/components/Error/Error.tsx +22 -0
- package/src/shared/libs/VideoPlayerControls/components/Error/index.ts +1 -0
- package/src/shared/libs/VideoPlayerControls/components/Error/styles.ts +21 -0
- package/src/shared/libs/VideoPlayerControls/components/Fullscreen.tsx +36 -0
- package/src/shared/libs/VideoPlayerControls/components/Loader/Loader.tsx +15 -0
- package/src/shared/libs/VideoPlayerControls/components/Loader/index.ts +1 -0
- package/src/shared/libs/VideoPlayerControls/components/Loader/styles.ts +16 -0
- package/src/shared/libs/VideoPlayerControls/components/NullControl.tsx +7 -0
- package/src/shared/libs/VideoPlayerControls/components/Overlay.tsx +23 -0
- package/src/shared/libs/VideoPlayerControls/components/PlayPause/PlayPause.tsx +109 -0
- package/src/shared/libs/VideoPlayerControls/components/PlayPause/index.ts +1 -0
- package/src/shared/libs/VideoPlayerControls/components/PlayPause/styles.ts +21 -0
- package/src/shared/libs/VideoPlayerControls/components/Seekbar/Seekbar.tsx +47 -0
- package/src/shared/libs/VideoPlayerControls/components/Seekbar/index.ts +1 -0
- package/src/shared/libs/VideoPlayerControls/components/Seekbar/styles.ts +37 -0
- package/src/shared/libs/VideoPlayerControls/components/Timer/Timer.tsx +28 -0
- package/src/shared/libs/VideoPlayerControls/components/Timer/index.ts +1 -0
- package/src/shared/libs/VideoPlayerControls/components/Timer/styles.ts +12 -0
- package/src/shared/libs/VideoPlayerControls/components/Title.tsx +35 -0
- package/src/shared/libs/VideoPlayerControls/components/TopControls.tsx +110 -0
- package/src/shared/libs/VideoPlayerControls/components/Volume/Volume.tsx +37 -0
- package/src/shared/libs/VideoPlayerControls/components/Volume/index.ts +1 -0
- package/src/shared/libs/VideoPlayerControls/components/Volume/styles.ts +31 -0
- package/src/shared/libs/VideoPlayerControls/components/index.ts +14 -0
- package/src/shared/libs/VideoPlayerControls/components/styles.ts +30 -0
- package/src/shared/libs/VideoPlayerControls/hooks/index.ts +3 -0
- package/src/shared/libs/VideoPlayerControls/hooks/useAnimations.ts +68 -0
- package/src/shared/libs/VideoPlayerControls/hooks/useControlTimeout.tsx +67 -0
- package/src/shared/libs/VideoPlayerControls/hooks/usePanResponders.tsx +96 -0
- package/src/shared/libs/VideoPlayerControls/index.ts +4 -0
- package/src/shared/libs/VideoPlayerControls/styles.ts +19 -0
- package/src/shared/libs/VideoPlayerControls/types.ts +290 -0
- package/src/shared/libs/VideoPlayerControls/utils.ts +76 -0
- package/src/shared/modals/CometChatMessageTemplate.ts +113 -9
- package/src/shared/modals/InteractiveData/InteractiveMessage/SchedulerMessage.ts +23 -21
- package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/de/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/en/translation.json +6 -3
- package/src/shared/resources/CometChatLocalize/resources/es/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +4 -1
- package/src/shared/resources/CometChatTheme/Palette.ts +79 -45
- package/src/shared/resources/CometChatTheme/Typography.ts +18 -0
- package/src/shared/utils/CommonUtils.ts +71 -0
- package/src/shared/utils/PermissionUtilIOS.ts +104 -0
- package/src/shared/views/CometChatActionSheet/ActionSheetStyle.ts +3 -1
- package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +6 -6
- package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +28 -5
- package/src/shared/views/CometChatAudioBubble/style.ts +4 -2
- package/src/shared/views/CometChatAvatar/AvatarStyle.ts +1 -1
- package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +4 -3
- package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +47 -31
- package/src/shared/views/CometChatEmojiKeyboard/EmojiKeyboardConfiguration.ts +5 -5
- package/src/shared/views/CometChatEmojiKeyboard/EmojiKeyboardStyle.ts +12 -13
- package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +52 -5
- package/src/shared/views/CometChatFileBubble/style.ts +4 -2
- package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +25 -2
- package/src/shared/views/CometChatList/CometChatList.tsx +2 -1
- package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +51 -2
- package/src/shared/views/CometChatQuickReactions/CometChatQuickReactions.tsx +76 -0
- package/src/shared/views/CometChatQuickReactions/QuickReactionsConfiguration.tsx +12 -0
- package/src/shared/views/CometChatQuickReactions/QuickReactionsStyle.tsx +35 -0
- package/src/shared/views/CometChatQuickReactions/index.ts +12 -0
- package/src/shared/views/CometChatReactions/CometChatReactions.tsx +166 -0
- package/src/shared/views/CometChatReactions/ReactionsConfiguration.tsx +12 -0
- package/src/shared/views/CometChatReactions/ReactionsStyle.tsx +43 -0
- package/src/shared/views/CometChatReactions/index.ts +12 -0
- package/src/{extensions/Reactions/CometChatMessageReactions → shared/views/CometChatReactions}/style.ts +7 -7
- package/src/shared/views/CometChatReactionsList/CometChatReactionsList.tsx +335 -0
- package/src/shared/views/CometChatReactionsList/ReactionsListConfiguration.tsx +14 -0
- package/src/shared/views/CometChatReactionsList/ReactionsListStyle.tsx +67 -0
- package/src/shared/views/CometChatReactionsList/index.ts +12 -0
- package/src/shared/views/CometChatReactionsList/resources/Spineer.png +0 -0
- package/src/shared/views/CometChatReactionsList/resources/index.ts +5 -0
- package/src/shared/views/CometChatReceipt/CometChatReceipt.tsx +21 -4
- package/src/shared/views/CometChatReceipt/MessageConfiguration.ts +12 -0
- package/src/shared/views/CometChatReceipt/resources/error.png +0 -0
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +1 -1
- package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +78 -12
- package/src/shared/views/CometChatVideoBubble/VideoBubbleStyle.ts +52 -2
- package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +134 -0
- package/src/shared/views/CometChatVideoPlayer/index.tsx +1 -0
- package/src/shared/views/index.ts +30 -0
- package/android/.gradle/7.4.2/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4.2/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.4.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.4.2/gc.properties +0 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.idea/gradle.xml +0 -13
- package/android/.idea/misc.xml +0 -8
- package/android/.idea/modules/android.iml +0 -18
- package/android/.idea/modules.xml +0 -8
- package/android/.idea/vcs.xml +0 -6
- package/android/local.properties +0 -8
- package/src/extensions/Reactions/CometChatMessageReactions/CometChatMessageReactions.tsx +0 -249
- package/src/extensions/Reactions/CometChatMessageReactions/index.ts +0 -3
- package/src/extensions/Reactions/ReactionsDecorator.tsx +0 -164
- package/src/extensions/Reactions/ReactionsExtension.tsx +0 -48
- package/src/extensions/Reactions/index.ts +0 -4
- /package/src/{extensions/Reactions → shared/views/CometChatQuickReactions}/resources/AddReactions.png +0 -0
- /package/src/{extensions/Reactions → shared/views/CometChatQuickReactions}/resources/index.ts +0 -0
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
import React, {useCallback, useState, useEffect, useRef} from 'react';
|
|
2
|
+
import {View} from 'react-native';
|
|
3
|
+
import Video from '../VideoPlayer/Video';
|
|
4
|
+
import {useControlTimeout, useJSAnimations, usePanResponders} from './hooks';
|
|
5
|
+
import {
|
|
6
|
+
Error,
|
|
7
|
+
Loader,
|
|
8
|
+
TopControls,
|
|
9
|
+
BottomControls,
|
|
10
|
+
PlayPause,
|
|
11
|
+
Overlay,
|
|
12
|
+
} from './components';
|
|
13
|
+
import {PlatformSupport} from './OSSupport';
|
|
14
|
+
import {_onBack} from './utils';
|
|
15
|
+
import {_styles} from './styles';
|
|
16
|
+
import type {VideoPlayerProps, WithRequiredProperty} from './types';
|
|
17
|
+
|
|
18
|
+
const volumeWidth = 150;
|
|
19
|
+
const iconOffset = 0;
|
|
20
|
+
|
|
21
|
+
const AnimatedVideoPlayer = (
|
|
22
|
+
props: WithRequiredProperty<VideoPlayerProps, 'animations'>,
|
|
23
|
+
) => {
|
|
24
|
+
|
|
25
|
+
const {
|
|
26
|
+
loadingIconColor,
|
|
27
|
+
playIcon,
|
|
28
|
+
playIconColor,
|
|
29
|
+
pauseIcon,
|
|
30
|
+
pauseIconColor,
|
|
31
|
+
backIcon,
|
|
32
|
+
backIconColor,
|
|
33
|
+
volumeIcon,
|
|
34
|
+
volumeIconColor,
|
|
35
|
+
animations,
|
|
36
|
+
toggleResizeModeOnFullscreen,
|
|
37
|
+
doubleTapTime = 130,
|
|
38
|
+
resizeMode = 'contain',
|
|
39
|
+
isFullscreen = false,
|
|
40
|
+
showOnStart = false,
|
|
41
|
+
showOnEnd = false,
|
|
42
|
+
alwaysShowControls = false,
|
|
43
|
+
paused = false,
|
|
44
|
+
muted = false,
|
|
45
|
+
volume = 1,
|
|
46
|
+
title = '',
|
|
47
|
+
rate = 1,
|
|
48
|
+
showDuration = false,
|
|
49
|
+
showTimeRemaining = false,
|
|
50
|
+
showHours = false,
|
|
51
|
+
onSeek,
|
|
52
|
+
onError,
|
|
53
|
+
onBack,
|
|
54
|
+
onEnd,
|
|
55
|
+
onEnterFullscreen = () => {},
|
|
56
|
+
onExitFullscreen = () => {},
|
|
57
|
+
onHideControls = () => {},
|
|
58
|
+
onShowControls = () => {},
|
|
59
|
+
onPause,
|
|
60
|
+
onPlay,
|
|
61
|
+
onLoad,
|
|
62
|
+
onLoadStart,
|
|
63
|
+
onProgress,
|
|
64
|
+
controlTimeoutDelay = 15000,
|
|
65
|
+
tapAnywhereToPause = false,
|
|
66
|
+
videoStyle = {},
|
|
67
|
+
containerStyle = {},
|
|
68
|
+
seekColor = '',
|
|
69
|
+
source,
|
|
70
|
+
disableBack = false,
|
|
71
|
+
disableVolume = false,
|
|
72
|
+
disableFullscreen = false,
|
|
73
|
+
disableTimer = false,
|
|
74
|
+
disableSeekbar = false,
|
|
75
|
+
disablePlayPause = false,
|
|
76
|
+
disableSeekButtons = false,
|
|
77
|
+
disableOverlay,
|
|
78
|
+
navigator,
|
|
79
|
+
rewindTime = 15,
|
|
80
|
+
pan: {horizontal: horizontalPan, inverted: invertedPan} = {},
|
|
81
|
+
} = props;
|
|
82
|
+
|
|
83
|
+
const mounted = useRef(false);
|
|
84
|
+
const _videoRef = useRef<any>(null);
|
|
85
|
+
const controlTimeout = useRef<ReturnType<typeof setTimeout>>(
|
|
86
|
+
setTimeout(() => {}),
|
|
87
|
+
).current;
|
|
88
|
+
const tapActionTimeout = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
89
|
+
const [_resizeMode, setResizeMode] = useState<any>(resizeMode);
|
|
90
|
+
const [_paused, setPaused] = useState<boolean>(paused);
|
|
91
|
+
const [_muted, setMuted] = useState<boolean>(muted);
|
|
92
|
+
const [_volume, setVolume] = useState<number>(volume);
|
|
93
|
+
const [_isFullscreen, setIsFullscreen] = useState<boolean>(
|
|
94
|
+
isFullscreen || resizeMode === 'cover' || false,
|
|
95
|
+
);
|
|
96
|
+
const [_showTimeRemaining, setShowTimeRemaining] =
|
|
97
|
+
useState<boolean>(showTimeRemaining);
|
|
98
|
+
const [volumeTrackWidth, setVolumeTrackWidth] = useState<number>(0);
|
|
99
|
+
const [volumeFillWidth, setVolumeFillWidth] = useState<number>(0);
|
|
100
|
+
const [seekerFillWidth, setSeekerFillWidth] = useState<number>(0);
|
|
101
|
+
const [showControls, setShowControls] = useState(showOnStart);
|
|
102
|
+
const [volumePosition, setVolumePositionState] = useState(0);
|
|
103
|
+
const [seekerPosition, setSeekerPositionState] = useState(0);
|
|
104
|
+
const [volumeOffset, setVolumeOffset] = useState(0);
|
|
105
|
+
const [seekerOffset, setSeekerOffset] = useState(0);
|
|
106
|
+
const [seekerWidth, setSeekerWidth] = useState(0);
|
|
107
|
+
const [seeking, setSeeking] = useState(false);
|
|
108
|
+
const [loading, setLoading] = useState(true);
|
|
109
|
+
const [currentTime, setCurrentTime] = useState(0);
|
|
110
|
+
const [error, setError] = useState(false);
|
|
111
|
+
const [duration, setDuration] = useState(0);
|
|
112
|
+
|
|
113
|
+
const videoRef = props.videoRef || _videoRef;
|
|
114
|
+
|
|
115
|
+
const toggleFullscreen = () => setIsFullscreen((prevState) => !prevState);
|
|
116
|
+
const toggleControls = () =>
|
|
117
|
+
setShowControls((prevState) => alwaysShowControls || !prevState);
|
|
118
|
+
const toggleTimer = () => setShowTimeRemaining((prevState) => !prevState);
|
|
119
|
+
const togglePlayPause = () => {
|
|
120
|
+
setPaused((prevState) => !prevState);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const styles = {
|
|
124
|
+
videoStyle,
|
|
125
|
+
containerStyle: containerStyle,
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const _onSeek = (obj: any) => {
|
|
129
|
+
if (!seeking) {
|
|
130
|
+
setControlTimeout();
|
|
131
|
+
}
|
|
132
|
+
setCurrentTime(obj.seekTime);
|
|
133
|
+
|
|
134
|
+
if (typeof onSeek === 'function') {
|
|
135
|
+
onSeek(obj);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const _onEnd = () => {
|
|
140
|
+
if (currentTime < duration) {
|
|
141
|
+
setCurrentTime(duration);
|
|
142
|
+
setPaused(!props.repeat);
|
|
143
|
+
|
|
144
|
+
if (showOnEnd) {
|
|
145
|
+
setShowControls(!props.repeat);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (typeof onEnd === 'function') {
|
|
150
|
+
onEnd();
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const _onError = () => {
|
|
155
|
+
setError(true);
|
|
156
|
+
setLoading(false);
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
function _onLoadStart(e: any) {
|
|
160
|
+
setLoading(true);
|
|
161
|
+
|
|
162
|
+
if (typeof onLoadStart === 'function') {
|
|
163
|
+
onLoadStart(e);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function _onLoad(data: any) {
|
|
168
|
+
setDuration(data.duration);
|
|
169
|
+
setLoading(false);
|
|
170
|
+
|
|
171
|
+
if (showControls) {
|
|
172
|
+
setControlTimeout();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (typeof onLoad === 'function') {
|
|
176
|
+
onLoad(data);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function _onProgress(data: any) {
|
|
181
|
+
if (!seeking) {
|
|
182
|
+
setCurrentTime(data.currentTime);
|
|
183
|
+
|
|
184
|
+
if (typeof onProgress === 'function') {
|
|
185
|
+
onProgress(data);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const _onScreenTouch = () => {
|
|
191
|
+
if (tapActionTimeout.current) {
|
|
192
|
+
clearTimeout(tapActionTimeout.current);
|
|
193
|
+
tapActionTimeout.current = null;
|
|
194
|
+
toggleFullscreen();
|
|
195
|
+
if (showControls) {
|
|
196
|
+
resetControlTimeout();
|
|
197
|
+
}
|
|
198
|
+
} else {
|
|
199
|
+
tapActionTimeout.current = setTimeout(() => {
|
|
200
|
+
if (tapAnywhereToPause && showControls) {
|
|
201
|
+
togglePlayPause();
|
|
202
|
+
resetControlTimeout();
|
|
203
|
+
} else {
|
|
204
|
+
toggleControls();
|
|
205
|
+
}
|
|
206
|
+
tapActionTimeout.current = null;
|
|
207
|
+
}, doubleTapTime);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const events = {
|
|
212
|
+
onError: onError || _onError,
|
|
213
|
+
onBack: (onBack || _onBack(navigator)) as () => void,
|
|
214
|
+
onEnd: _onEnd,
|
|
215
|
+
onScreenTouch: _onScreenTouch,
|
|
216
|
+
onEnterFullscreen,
|
|
217
|
+
onExitFullscreen,
|
|
218
|
+
onShowControls,
|
|
219
|
+
onHideControls,
|
|
220
|
+
onLoadStart: _onLoadStart,
|
|
221
|
+
onProgress: _onProgress,
|
|
222
|
+
onSeek: _onSeek,
|
|
223
|
+
onLoad: _onLoad,
|
|
224
|
+
onPause,
|
|
225
|
+
onPlay,
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
const constrainToSeekerMinMax = useCallback(
|
|
229
|
+
(val = 0) => {
|
|
230
|
+
if (val <= 0) {
|
|
231
|
+
return 0;
|
|
232
|
+
} else if (val >= seekerWidth) {
|
|
233
|
+
return seekerWidth;
|
|
234
|
+
}
|
|
235
|
+
return val;
|
|
236
|
+
},
|
|
237
|
+
[seekerWidth],
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
const constrainToVolumeMinMax = (val = 0) => {
|
|
241
|
+
if (val <= 0) {
|
|
242
|
+
return 0;
|
|
243
|
+
} else if (val >= volumeWidth + 9) {
|
|
244
|
+
return volumeWidth + 9;
|
|
245
|
+
}
|
|
246
|
+
return val;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
const setSeekerPosition = useCallback(
|
|
250
|
+
(position = 0) => {
|
|
251
|
+
const positionValue = constrainToSeekerMinMax(position);
|
|
252
|
+
setSeekerPositionState(positionValue);
|
|
253
|
+
setSeekerOffset(positionValue);
|
|
254
|
+
setSeekerFillWidth(positionValue);
|
|
255
|
+
},
|
|
256
|
+
[constrainToSeekerMinMax],
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
const setVolumePosition = (position = 0) => {
|
|
260
|
+
const positionValue = constrainToVolumeMinMax(position);
|
|
261
|
+
setVolumePositionState(positionValue + iconOffset);
|
|
262
|
+
|
|
263
|
+
if (positionValue < 0) {
|
|
264
|
+
setVolumeFillWidth(0);
|
|
265
|
+
} else {
|
|
266
|
+
setVolumeFillWidth(positionValue);
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
const {clearControlTimeout, resetControlTimeout, setControlTimeout} =
|
|
271
|
+
useControlTimeout({
|
|
272
|
+
controlTimeout,
|
|
273
|
+
controlTimeoutDelay,
|
|
274
|
+
mounted: mounted.current,
|
|
275
|
+
showControls,
|
|
276
|
+
setShowControls,
|
|
277
|
+
alwaysShowControls,
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const {volumePanResponder, seekPanResponder} = usePanResponders({
|
|
281
|
+
duration,
|
|
282
|
+
seekerOffset,
|
|
283
|
+
volumeOffset,
|
|
284
|
+
loading,
|
|
285
|
+
seekerWidth,
|
|
286
|
+
seeking,
|
|
287
|
+
seekerPosition,
|
|
288
|
+
seek: videoRef?.current?.seek,
|
|
289
|
+
clearControlTimeout,
|
|
290
|
+
setVolumePosition,
|
|
291
|
+
setSeekerPosition,
|
|
292
|
+
setSeeking,
|
|
293
|
+
setControlTimeout,
|
|
294
|
+
onEnd: events.onEnd,
|
|
295
|
+
horizontal: horizontalPan,
|
|
296
|
+
inverted: invertedPan,
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
useEffect(() => {
|
|
300
|
+
if (currentTime >= duration) {
|
|
301
|
+
videoRef?.current?.seek(0);
|
|
302
|
+
}
|
|
303
|
+
}, [currentTime, duration, videoRef]);
|
|
304
|
+
|
|
305
|
+
useEffect(() => {
|
|
306
|
+
if (toggleResizeModeOnFullscreen) {
|
|
307
|
+
setResizeMode(_isFullscreen ? 'cover' : 'contain');
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (_isFullscreen) {
|
|
311
|
+
typeof events.onEnterFullscreen === 'function' &&
|
|
312
|
+
events.onEnterFullscreen();
|
|
313
|
+
} else {
|
|
314
|
+
typeof events.onExitFullscreen === 'function' &&
|
|
315
|
+
events.onExitFullscreen();
|
|
316
|
+
}
|
|
317
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
318
|
+
}, [_isFullscreen, toggleResizeModeOnFullscreen]);
|
|
319
|
+
|
|
320
|
+
useEffect(() => {
|
|
321
|
+
setIsFullscreen(isFullscreen);
|
|
322
|
+
}, [isFullscreen]);
|
|
323
|
+
|
|
324
|
+
useEffect(() => {
|
|
325
|
+
setPaused(paused);
|
|
326
|
+
mounted.current = true;
|
|
327
|
+
return () => {
|
|
328
|
+
mounted.current = false;
|
|
329
|
+
};
|
|
330
|
+
}, [paused]);
|
|
331
|
+
|
|
332
|
+
useEffect(() => {
|
|
333
|
+
if (_paused) {
|
|
334
|
+
typeof events.onPause === 'function' && events.onPause();
|
|
335
|
+
} else {
|
|
336
|
+
typeof events.onPlay === 'function' && events.onPlay();
|
|
337
|
+
}
|
|
338
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
339
|
+
}, [_paused]);
|
|
340
|
+
|
|
341
|
+
useEffect(() => {
|
|
342
|
+
if (!seeking && currentTime && duration) {
|
|
343
|
+
const percent = currentTime / duration;
|
|
344
|
+
const position = seekerWidth * percent;
|
|
345
|
+
|
|
346
|
+
setSeekerPosition(position);
|
|
347
|
+
}
|
|
348
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
349
|
+
}, [currentTime, duration, seekerWidth, setSeekerPosition]);
|
|
350
|
+
|
|
351
|
+
useEffect(() => {
|
|
352
|
+
if (showControls && !loading) {
|
|
353
|
+
animations.showControlAnimation();
|
|
354
|
+
setControlTimeout();
|
|
355
|
+
typeof events.onShowControls === 'function' && events.onShowControls();
|
|
356
|
+
} else {
|
|
357
|
+
animations.hideControlAnimation();
|
|
358
|
+
clearControlTimeout();
|
|
359
|
+
typeof events.onHideControls === 'function' && events.onHideControls();
|
|
360
|
+
}
|
|
361
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
362
|
+
}, [showControls, loading]);
|
|
363
|
+
|
|
364
|
+
useEffect(() => {
|
|
365
|
+
setMuted(muted);
|
|
366
|
+
}, [muted]);
|
|
367
|
+
|
|
368
|
+
useEffect(() => {
|
|
369
|
+
const newVolume = volumePosition / volumeWidth;
|
|
370
|
+
|
|
371
|
+
if (newVolume <= 0) {
|
|
372
|
+
setMuted(true);
|
|
373
|
+
} else {
|
|
374
|
+
setMuted(false);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
setVolume(newVolume);
|
|
378
|
+
setVolumeOffset(volumePosition);
|
|
379
|
+
|
|
380
|
+
const newVolumeTrackWidth = volumeWidth - volumeFillWidth;
|
|
381
|
+
|
|
382
|
+
if (newVolumeTrackWidth > 150) {
|
|
383
|
+
setVolumeTrackWidth(150);
|
|
384
|
+
} else {
|
|
385
|
+
setVolumeTrackWidth(newVolumeTrackWidth);
|
|
386
|
+
}
|
|
387
|
+
}, [volumeFillWidth, volumePosition]);
|
|
388
|
+
|
|
389
|
+
useEffect(() => {
|
|
390
|
+
const position = volumeWidth * _volume;
|
|
391
|
+
setVolumePosition(position);
|
|
392
|
+
setVolumeOffset(position);
|
|
393
|
+
mounted.current = true;
|
|
394
|
+
return () => {
|
|
395
|
+
mounted.current = false;
|
|
396
|
+
clearControlTimeout();
|
|
397
|
+
};
|
|
398
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
399
|
+
}, []);
|
|
400
|
+
|
|
401
|
+
return (
|
|
402
|
+
<PlatformSupport
|
|
403
|
+
showControls={showControls}
|
|
404
|
+
containerStyles={styles.containerStyle}
|
|
405
|
+
onScreenTouch={events.onScreenTouch}>
|
|
406
|
+
<View style={[_styles.player.container, styles.containerStyle]}>
|
|
407
|
+
<Video
|
|
408
|
+
{...props}
|
|
409
|
+
{...events}
|
|
410
|
+
ref={videoRef || _videoRef}
|
|
411
|
+
resizeMode={_resizeMode}
|
|
412
|
+
volume={_volume}
|
|
413
|
+
paused={_paused}
|
|
414
|
+
muted={_muted}
|
|
415
|
+
rate={rate}
|
|
416
|
+
style={[_styles.player.video, styles.videoStyle]}
|
|
417
|
+
source={source}
|
|
418
|
+
/>
|
|
419
|
+
{loading ? (
|
|
420
|
+
<Loader loadingIconColor={loadingIconColor}/>
|
|
421
|
+
) : (
|
|
422
|
+
<>
|
|
423
|
+
<Error error={error} />
|
|
424
|
+
{!disableOverlay && <Overlay animations={animations} />}
|
|
425
|
+
<TopControls
|
|
426
|
+
panHandlers={volumePanResponder.panHandlers}
|
|
427
|
+
animations={animations}
|
|
428
|
+
disableBack={disableBack}
|
|
429
|
+
disableVolume={disableVolume}
|
|
430
|
+
volumeFillWidth={volumeFillWidth}
|
|
431
|
+
volumeTrackWidth={volumeTrackWidth}
|
|
432
|
+
volumePosition={volumePosition}
|
|
433
|
+
onBack={events.onBack}
|
|
434
|
+
resetControlTimeout={resetControlTimeout}
|
|
435
|
+
showControls={showControls}
|
|
436
|
+
backIcon={backIcon}
|
|
437
|
+
backIconColor={backIconColor}
|
|
438
|
+
volumeIcon={volumeIcon}
|
|
439
|
+
volumeIconColor={volumeIconColor}
|
|
440
|
+
/>
|
|
441
|
+
<PlayPause
|
|
442
|
+
animations={animations}
|
|
443
|
+
disablePlayPause={disablePlayPause}
|
|
444
|
+
disableSeekButtons={disableSeekButtons}
|
|
445
|
+
paused={_paused}
|
|
446
|
+
togglePlayPause={togglePlayPause}
|
|
447
|
+
resetControlTimeout={resetControlTimeout}
|
|
448
|
+
showControls={showControls}
|
|
449
|
+
onPressRewind={() =>
|
|
450
|
+
videoRef?.current?.seek(currentTime - rewindTime)
|
|
451
|
+
}
|
|
452
|
+
onPressForward={() =>
|
|
453
|
+
videoRef?.current?.seek(currentTime + rewindTime)
|
|
454
|
+
}
|
|
455
|
+
playIcon={playIcon}
|
|
456
|
+
playIconColor={playIconColor}
|
|
457
|
+
pauseIcon={pauseIcon}
|
|
458
|
+
pauseIconColor={pauseIconColor}
|
|
459
|
+
/>
|
|
460
|
+
<BottomControls
|
|
461
|
+
animations={animations}
|
|
462
|
+
panHandlers={seekPanResponder.panHandlers}
|
|
463
|
+
disableTimer={disableTimer}
|
|
464
|
+
disableSeekbar={disableSeekbar}
|
|
465
|
+
showHours={showHours}
|
|
466
|
+
showDuration={showDuration}
|
|
467
|
+
paused={_paused}
|
|
468
|
+
showTimeRemaining={_showTimeRemaining}
|
|
469
|
+
currentTime={currentTime}
|
|
470
|
+
duration={duration}
|
|
471
|
+
seekColor={seekColor}
|
|
472
|
+
title={title}
|
|
473
|
+
toggleTimer={toggleTimer}
|
|
474
|
+
resetControlTimeout={resetControlTimeout}
|
|
475
|
+
seekerFillWidth={seekerFillWidth}
|
|
476
|
+
seekerPosition={seekerPosition}
|
|
477
|
+
setSeekerWidth={setSeekerWidth}
|
|
478
|
+
isFullscreen={isFullscreen}
|
|
479
|
+
disableFullscreen={disableFullscreen}
|
|
480
|
+
toggleFullscreen={toggleFullscreen}
|
|
481
|
+
showControls={showControls}
|
|
482
|
+
/>
|
|
483
|
+
</>
|
|
484
|
+
)}
|
|
485
|
+
</View>
|
|
486
|
+
</PlatformSupport>
|
|
487
|
+
);
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
const CustomAnimations = ({
|
|
491
|
+
useAnimations,
|
|
492
|
+
controlAnimationTiming = 450,
|
|
493
|
+
...props
|
|
494
|
+
}: WithRequiredProperty<VideoPlayerProps, 'useAnimations'>) => {
|
|
495
|
+
const animations = useAnimations(controlAnimationTiming);
|
|
496
|
+
return <AnimatedVideoPlayer animations={animations} {...props} />;
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
const JSAnimations = (props: VideoPlayerProps) => {
|
|
500
|
+
const animations = useJSAnimations(props.controlAnimationTiming);
|
|
501
|
+
|
|
502
|
+
return <AnimatedVideoPlayer animations={animations} {...props} />;
|
|
503
|
+
};
|
|
504
|
+
|
|
505
|
+
export const VideoPlayer = (props: Omit<VideoPlayerProps, 'animations'>) => {
|
|
506
|
+
if (props?.useAnimations) {
|
|
507
|
+
return <CustomAnimations useAnimations={props?.useAnimations} {...props} />;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
return <JSAnimations {...props} />;
|
|
511
|
+
};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {Image, ImageSourcePropType} from 'react-native';
|
|
3
|
+
import {Control} from '../Control';
|
|
4
|
+
|
|
5
|
+
interface BackProps {
|
|
6
|
+
onBack: () => void;
|
|
7
|
+
resetControlTimeout?: () => void;
|
|
8
|
+
showControls: boolean;
|
|
9
|
+
backIcon?: ImageSourcePropType
|
|
10
|
+
backIconColor?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const Back = ({
|
|
14
|
+
backIcon,
|
|
15
|
+
backIconColor,
|
|
16
|
+
onBack,
|
|
17
|
+
showControls
|
|
18
|
+
}: BackProps) => {
|
|
19
|
+
return (
|
|
20
|
+
<Control callback={onBack} disabled={!showControls}>
|
|
21
|
+
<Image
|
|
22
|
+
source={backIcon ? backIcon : require('../../assets/img/back.png')}
|
|
23
|
+
resizeMode='contain'
|
|
24
|
+
style={backIconColor ? { tintColor: backIconColor } : {}}
|
|
25
|
+
/>
|
|
26
|
+
</Control>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Back';
|