@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.
Files changed (227) hide show
  1. package/README.md +26 -67
  2. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  3. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  4. package/android/build.gradle +1 -1
  5. package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +2 -1
  6. package/android/src/main/java/com/reactnativecometchatuikit/ReactVideoView.java +796 -0
  7. package/android/src/main/java/com/reactnativecometchatuikit/ReactVideoViewManager.java +172 -0
  8. package/android/src/main/java/com/scalablevideoview/BuildConfig.java +10 -0
  9. package/android/src/main/java/com/scalablevideoview/PivotPoint.java +13 -0
  10. package/android/src/main/java/com/scalablevideoview/ScalableType.java +34 -0
  11. package/android/src/main/java/com/scalablevideoview/ScalableVideoView.java +255 -0
  12. package/android/src/main/java/com/scalablevideoview/ScaleManager.java +188 -0
  13. package/android/src/main/java/com/scalablevideoview/Size.java +20 -0
  14. package/android/src/main/java/com/zipfile/APEZProvider.java +287 -0
  15. package/android/src/main/java/com/zipfile/APKExpansionSupport.java +81 -0
  16. package/android/src/main/java/com/zipfile/ZipResourceFile.java +428 -0
  17. package/android/src/main/res/values/attrs.xml +37 -0
  18. package/ios/FileManager.m +75 -5
  19. package/ios/Video/CCRCTVideo.h +67 -0
  20. package/ios/Video/CCRCTVideo.m +2031 -0
  21. package/ios/Video/CCRCTVideoManager.h +6 -0
  22. package/ios/Video/CCRCTVideoManager.m +133 -0
  23. package/ios/Video/CCRCTVideoPlayerViewController.h +20 -0
  24. package/ios/Video/CCRCTVideoPlayerViewController.m +43 -0
  25. package/ios/Video/CCRCTVideoPlayerViewControllerDelegate.h +7 -0
  26. package/ios/Video/UIView+FindUIViewController.h +15 -0
  27. package/ios/Video/UIView+FindUIViewController.m +21 -0
  28. package/ios/VideoCaching/RCTVideoCache.h +38 -0
  29. package/ios/VideoCaching/RCTVideoCache.m +174 -0
  30. package/ios/VideoPickerModule.h +7 -0
  31. package/ios/VideoPickerModule.mm +95 -0
  32. package/package.json +3 -4
  33. package/react-native-cometchat-ui-kit.podspec +24 -10
  34. package/src/CometChatContacts/CometChatContacts.tsx +12 -9
  35. package/src/CometChatConversations/CometChatConversations.tsx +84 -64
  36. package/src/CometChatDetails/CometChatDetails.tsx +14 -12
  37. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +8 -4
  38. package/src/CometChatGroupMembers/resources/check.png +0 -0
  39. package/src/CometChatGroupMembers/resources/index.ts +2 -0
  40. package/src/CometChatGroups/CometChatGroups.tsx +4 -4
  41. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +57 -15
  42. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +9 -2
  43. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +1 -1
  44. package/src/CometChatMessageList/CometChatMessageList.tsx +596 -181
  45. package/src/CometChatMessageList/MessageListConfiguration.ts +55 -4
  46. package/src/CometChatMessageList/resources/index.ts +5 -1
  47. package/src/CometChatMessageList/resources/leftarrowcurve.png +0 -0
  48. package/src/CometChatMessageList/resources/rightarrowcurve.png +0 -0
  49. package/src/CometChatMessages/CometChatMessages.tsx +1 -1
  50. package/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx +4 -12
  51. package/src/CometChatThreadedMessages/style.ts +3 -1
  52. package/src/CometChatUsers/CometChatUsers.tsx +1 -1
  53. package/src/calls/CallUtils.ts +4 -8
  54. package/src/calls/CallingExtentionDecorator.tsx +5 -2
  55. package/src/calls/CometChatCallBubble/styles.ts +2 -1
  56. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +14 -3
  57. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +9 -9
  58. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +80 -73
  59. package/src/extensions/CollaborativeBubble/styles.ts +2 -0
  60. package/src/extensions/SmartReplies/SmartRepliesDecorator.tsx +11 -0
  61. package/src/extensions/index.ts +0 -4
  62. package/src/index.ts +53 -8
  63. package/src/shared/CometChatUiKit/CometChatUIKit.ts +14 -2
  64. package/src/shared/constants/UIKitConstants.ts +1 -0
  65. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +6 -0
  66. package/src/shared/events/CometChatUIEventHandler/Listener.ts +8 -0
  67. package/src/shared/events/ListenerInitializer.ts +6 -0
  68. package/src/shared/events/messages.ts +2 -0
  69. package/src/shared/framework/MessageDataSource.tsx +29 -25
  70. package/src/shared/index.ts +49 -1
  71. package/src/shared/libs/VideoPlayer/DRMType.js +6 -0
  72. package/src/shared/libs/VideoPlayer/FilterType.js +18 -0
  73. package/src/shared/libs/VideoPlayer/TextTrackType.js +5 -0
  74. package/src/shared/libs/VideoPlayer/Video.js +519 -0
  75. package/src/shared/libs/VideoPlayer/VideoResizeMode.js +5 -0
  76. package/src/shared/libs/VideoPlayerControls/OSSupport/PlatformSupport.tsx +43 -0
  77. package/src/shared/libs/VideoPlayerControls/OSSupport/TVOSSupport.tsx +16 -0
  78. package/src/shared/libs/VideoPlayerControls/OSSupport/index.tsx +1 -0
  79. package/src/shared/libs/VideoPlayerControls/VideoPlayer.tsx +511 -0
  80. package/src/shared/libs/VideoPlayerControls/assets/img/back.png +0 -0
  81. package/src/shared/libs/VideoPlayerControls/assets/img/back@2x.png +0 -0
  82. package/src/shared/libs/VideoPlayerControls/assets/img/back@3x.png +0 -0
  83. package/src/shared/libs/VideoPlayerControls/assets/img/bottom-vignette.png +0 -0
  84. package/src/shared/libs/VideoPlayerControls/assets/img/bottom-vignette@2x.png +0 -0
  85. package/src/shared/libs/VideoPlayerControls/assets/img/bottom-vignette@3x.png +0 -0
  86. package/src/shared/libs/VideoPlayerControls/assets/img/error-icon.png +0 -0
  87. package/src/shared/libs/VideoPlayerControls/assets/img/error-icon@2x.png +0 -0
  88. package/src/shared/libs/VideoPlayerControls/assets/img/error-icon@3x.png +0 -0
  89. package/src/shared/libs/VideoPlayerControls/assets/img/expand.png +0 -0
  90. package/src/shared/libs/VideoPlayerControls/assets/img/expand@2x.png +0 -0
  91. package/src/shared/libs/VideoPlayerControls/assets/img/expand@3x.png +0 -0
  92. package/src/shared/libs/VideoPlayerControls/assets/img/forward.png +0 -0
  93. package/src/shared/libs/VideoPlayerControls/assets/img/forward@2x.png +0 -0
  94. package/src/shared/libs/VideoPlayerControls/assets/img/forward@3x.png +0 -0
  95. package/src/shared/libs/VideoPlayerControls/assets/img/loader-icon.png +0 -0
  96. package/src/shared/libs/VideoPlayerControls/assets/img/loader-icon@2x.png +0 -0
  97. package/src/shared/libs/VideoPlayerControls/assets/img/loader-icon@3x.png +0 -0
  98. package/src/shared/libs/VideoPlayerControls/assets/img/pause.png +0 -0
  99. package/src/shared/libs/VideoPlayerControls/assets/img/pause@2x.png +0 -0
  100. package/src/shared/libs/VideoPlayerControls/assets/img/pause@3x.png +0 -0
  101. package/src/shared/libs/VideoPlayerControls/assets/img/play.png +0 -0
  102. package/src/shared/libs/VideoPlayerControls/assets/img/play@2x.png +0 -0
  103. package/src/shared/libs/VideoPlayerControls/assets/img/play@3x.png +0 -0
  104. package/src/shared/libs/VideoPlayerControls/assets/img/rewind.png +0 -0
  105. package/src/shared/libs/VideoPlayerControls/assets/img/rewind@2x.png +0 -0
  106. package/src/shared/libs/VideoPlayerControls/assets/img/rewind@3x.png +0 -0
  107. package/src/shared/libs/VideoPlayerControls/assets/img/shrink.png +0 -0
  108. package/src/shared/libs/VideoPlayerControls/assets/img/shrink@2x.png +0 -0
  109. package/src/shared/libs/VideoPlayerControls/assets/img/shrink@3x.png +0 -0
  110. package/src/shared/libs/VideoPlayerControls/assets/img/top-vignette.png +0 -0
  111. package/src/shared/libs/VideoPlayerControls/assets/img/top-vignette@2x.png +0 -0
  112. package/src/shared/libs/VideoPlayerControls/assets/img/top-vignette@3x.png +0 -0
  113. package/src/shared/libs/VideoPlayerControls/assets/img/volume.png +0 -0
  114. package/src/shared/libs/VideoPlayerControls/assets/img/volume@2x.png +0 -0
  115. package/src/shared/libs/VideoPlayerControls/assets/img/volume@3x.png +0 -0
  116. package/src/shared/libs/VideoPlayerControls/components/Back/Back.tsx +28 -0
  117. package/src/shared/libs/VideoPlayerControls/components/Back/index.ts +1 -0
  118. package/src/shared/libs/VideoPlayerControls/components/BottomControls.tsx +142 -0
  119. package/src/shared/libs/VideoPlayerControls/components/Control.tsx +45 -0
  120. package/src/shared/libs/VideoPlayerControls/components/Error/Error.tsx +22 -0
  121. package/src/shared/libs/VideoPlayerControls/components/Error/index.ts +1 -0
  122. package/src/shared/libs/VideoPlayerControls/components/Error/styles.ts +21 -0
  123. package/src/shared/libs/VideoPlayerControls/components/Fullscreen.tsx +36 -0
  124. package/src/shared/libs/VideoPlayerControls/components/Loader/Loader.tsx +15 -0
  125. package/src/shared/libs/VideoPlayerControls/components/Loader/index.ts +1 -0
  126. package/src/shared/libs/VideoPlayerControls/components/Loader/styles.ts +16 -0
  127. package/src/shared/libs/VideoPlayerControls/components/NullControl.tsx +7 -0
  128. package/src/shared/libs/VideoPlayerControls/components/Overlay.tsx +23 -0
  129. package/src/shared/libs/VideoPlayerControls/components/PlayPause/PlayPause.tsx +109 -0
  130. package/src/shared/libs/VideoPlayerControls/components/PlayPause/index.ts +1 -0
  131. package/src/shared/libs/VideoPlayerControls/components/PlayPause/styles.ts +21 -0
  132. package/src/shared/libs/VideoPlayerControls/components/Seekbar/Seekbar.tsx +47 -0
  133. package/src/shared/libs/VideoPlayerControls/components/Seekbar/index.ts +1 -0
  134. package/src/shared/libs/VideoPlayerControls/components/Seekbar/styles.ts +37 -0
  135. package/src/shared/libs/VideoPlayerControls/components/Timer/Timer.tsx +28 -0
  136. package/src/shared/libs/VideoPlayerControls/components/Timer/index.ts +1 -0
  137. package/src/shared/libs/VideoPlayerControls/components/Timer/styles.ts +12 -0
  138. package/src/shared/libs/VideoPlayerControls/components/Title.tsx +35 -0
  139. package/src/shared/libs/VideoPlayerControls/components/TopControls.tsx +110 -0
  140. package/src/shared/libs/VideoPlayerControls/components/Volume/Volume.tsx +37 -0
  141. package/src/shared/libs/VideoPlayerControls/components/Volume/index.ts +1 -0
  142. package/src/shared/libs/VideoPlayerControls/components/Volume/styles.ts +31 -0
  143. package/src/shared/libs/VideoPlayerControls/components/index.ts +14 -0
  144. package/src/shared/libs/VideoPlayerControls/components/styles.ts +30 -0
  145. package/src/shared/libs/VideoPlayerControls/hooks/index.ts +3 -0
  146. package/src/shared/libs/VideoPlayerControls/hooks/useAnimations.ts +68 -0
  147. package/src/shared/libs/VideoPlayerControls/hooks/useControlTimeout.tsx +67 -0
  148. package/src/shared/libs/VideoPlayerControls/hooks/usePanResponders.tsx +96 -0
  149. package/src/shared/libs/VideoPlayerControls/index.ts +4 -0
  150. package/src/shared/libs/VideoPlayerControls/styles.ts +19 -0
  151. package/src/shared/libs/VideoPlayerControls/types.ts +290 -0
  152. package/src/shared/libs/VideoPlayerControls/utils.ts +76 -0
  153. package/src/shared/modals/CometChatMessageTemplate.ts +113 -9
  154. package/src/shared/modals/InteractiveData/InteractiveMessage/SchedulerMessage.ts +23 -21
  155. package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +4 -1
  156. package/src/shared/resources/CometChatLocalize/resources/de/translation.json +4 -1
  157. package/src/shared/resources/CometChatLocalize/resources/en/translation.json +6 -3
  158. package/src/shared/resources/CometChatLocalize/resources/es/translation.json +4 -1
  159. package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +4 -1
  160. package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +4 -1
  161. package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +4 -1
  162. package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +4 -1
  163. package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +4 -1
  164. package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +4 -1
  165. package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +4 -1
  166. package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +4 -1
  167. package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +4 -1
  168. package/src/shared/resources/CometChatTheme/Palette.ts +79 -45
  169. package/src/shared/resources/CometChatTheme/Typography.ts +18 -0
  170. package/src/shared/utils/CommonUtils.ts +71 -0
  171. package/src/shared/utils/PermissionUtilIOS.ts +104 -0
  172. package/src/shared/views/CometChatActionSheet/ActionSheetStyle.ts +3 -1
  173. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +6 -6
  174. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +28 -5
  175. package/src/shared/views/CometChatAudioBubble/style.ts +4 -2
  176. package/src/shared/views/CometChatAvatar/AvatarStyle.ts +1 -1
  177. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +4 -3
  178. package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +47 -31
  179. package/src/shared/views/CometChatEmojiKeyboard/EmojiKeyboardConfiguration.ts +5 -5
  180. package/src/shared/views/CometChatEmojiKeyboard/EmojiKeyboardStyle.ts +12 -13
  181. package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +52 -5
  182. package/src/shared/views/CometChatFileBubble/style.ts +4 -2
  183. package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +25 -2
  184. package/src/shared/views/CometChatList/CometChatList.tsx +2 -1
  185. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +51 -2
  186. package/src/shared/views/CometChatQuickReactions/CometChatQuickReactions.tsx +76 -0
  187. package/src/shared/views/CometChatQuickReactions/QuickReactionsConfiguration.tsx +12 -0
  188. package/src/shared/views/CometChatQuickReactions/QuickReactionsStyle.tsx +35 -0
  189. package/src/shared/views/CometChatQuickReactions/index.ts +12 -0
  190. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +166 -0
  191. package/src/shared/views/CometChatReactions/ReactionsConfiguration.tsx +12 -0
  192. package/src/shared/views/CometChatReactions/ReactionsStyle.tsx +43 -0
  193. package/src/shared/views/CometChatReactions/index.ts +12 -0
  194. package/src/{extensions/Reactions/CometChatMessageReactions → shared/views/CometChatReactions}/style.ts +7 -7
  195. package/src/shared/views/CometChatReactionsList/CometChatReactionsList.tsx +335 -0
  196. package/src/shared/views/CometChatReactionsList/ReactionsListConfiguration.tsx +14 -0
  197. package/src/shared/views/CometChatReactionsList/ReactionsListStyle.tsx +67 -0
  198. package/src/shared/views/CometChatReactionsList/index.ts +12 -0
  199. package/src/shared/views/CometChatReactionsList/resources/Spineer.png +0 -0
  200. package/src/shared/views/CometChatReactionsList/resources/index.ts +5 -0
  201. package/src/shared/views/CometChatReceipt/CometChatReceipt.tsx +21 -4
  202. package/src/shared/views/CometChatReceipt/MessageConfiguration.ts +12 -0
  203. package/src/shared/views/CometChatReceipt/resources/error.png +0 -0
  204. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +1 -1
  205. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +78 -12
  206. package/src/shared/views/CometChatVideoBubble/VideoBubbleStyle.ts +52 -2
  207. package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +134 -0
  208. package/src/shared/views/CometChatVideoPlayer/index.tsx +1 -0
  209. package/src/shared/views/index.ts +30 -0
  210. package/android/.gradle/7.4.2/checksums/checksums.lock +0 -0
  211. package/android/.gradle/7.4.2/fileChanges/last-build.bin +0 -0
  212. package/android/.gradle/7.4.2/fileHashes/fileHashes.lock +0 -0
  213. package/android/.gradle/7.4.2/gc.properties +0 -0
  214. package/android/.gradle/checksums/checksums.lock +0 -0
  215. package/android/.idea/gradle.xml +0 -13
  216. package/android/.idea/misc.xml +0 -8
  217. package/android/.idea/modules/android.iml +0 -18
  218. package/android/.idea/modules.xml +0 -8
  219. package/android/.idea/vcs.xml +0 -6
  220. package/android/local.properties +0 -8
  221. package/src/extensions/Reactions/CometChatMessageReactions/CometChatMessageReactions.tsx +0 -249
  222. package/src/extensions/Reactions/CometChatMessageReactions/index.ts +0 -3
  223. package/src/extensions/Reactions/ReactionsDecorator.tsx +0 -164
  224. package/src/extensions/Reactions/ReactionsExtension.tsx +0 -48
  225. package/src/extensions/Reactions/index.ts +0 -4
  226. /package/src/{extensions/Reactions → shared/views/CometChatQuickReactions}/resources/AddReactions.png +0 -0
  227. /package/src/{extensions/Reactions → shared/views/CometChatQuickReactions}/resources/index.ts +0 -0
@@ -0,0 +1,172 @@
1
+ package com.reactnativecometchatuikit;
2
+
3
+ import com.reactnativecometchatuikit.ReactVideoView.Events;
4
+ import com.facebook.react.bridge.Arguments;
5
+ import com.facebook.react.bridge.ReadableMap;
6
+ import com.facebook.react.bridge.WritableMap;
7
+ import com.facebook.react.common.MapBuilder;
8
+ import com.facebook.react.uimanager.annotations.ReactProp;
9
+ import com.facebook.react.uimanager.SimpleViewManager;
10
+ import com.facebook.react.uimanager.ThemedReactContext;
11
+ import com.facebook.react.uimanager.events.RCTEventEmitter;
12
+ import com.scalablevideoview.ScalableType;
13
+
14
+ import javax.annotation.Nullable;
15
+ import java.util.Map;
16
+
17
+ public class ReactVideoViewManager extends SimpleViewManager<ReactVideoView> {
18
+
19
+ public static final String REACT_CLASS = "CCRCTVideo";
20
+
21
+ public static final String PROP_SRC = "src";
22
+ public static final String PROP_SRC_URI = "uri";
23
+ public static final String PROP_SRC_TYPE = "type";
24
+ public static final String PROP_SRC_HEADERS = "requestHeaders";
25
+ public static final String PROP_SRC_IS_NETWORK = "isNetwork";
26
+ public static final String PROP_SRC_MAINVER = "mainVer";
27
+ public static final String PROP_SRC_PATCHVER = "patchVer";
28
+ public static final String PROP_SRC_IS_ASSET = "isAsset";
29
+ public static final String PROP_RESIZE_MODE = "resizeMode";
30
+ public static final String PROP_REPEAT = "repeat";
31
+ public static final String PROP_PAUSED = "paused";
32
+ public static final String PROP_MUTED = "muted";
33
+ public static final String PROP_PREVENTS_DISPLAY_SLEEP_DURING_VIDEO_PLAYBACK = "preventsDisplaySleepDuringVideoPlayback";
34
+ public static final String PROP_VOLUME = "volume";
35
+ public static final String PROP_STEREO_PAN = "stereoPan";
36
+ public static final String PROP_PROGRESS_UPDATE_INTERVAL = "progressUpdateInterval";
37
+ public static final String PROP_SEEK = "seek";
38
+ public static final String PROP_RATE = "rate";
39
+ public static final String PROP_FULLSCREEN = "fullscreen";
40
+ public static final String PROP_PLAY_IN_BACKGROUND = "playInBackground";
41
+ public static final String PROP_CONTROLS = "controls";
42
+
43
+ @Override
44
+ public String getName() {
45
+ return REACT_CLASS;
46
+ }
47
+
48
+ @Override
49
+ protected ReactVideoView createViewInstance(ThemedReactContext themedReactContext) {
50
+ return new ReactVideoView(themedReactContext);
51
+ }
52
+
53
+ @Override
54
+ public void onDropViewInstance(ReactVideoView view) {
55
+ super.onDropViewInstance(view);
56
+ view.cleanupMediaPlayerResources();
57
+ }
58
+
59
+ @Override
60
+ @Nullable
61
+ public Map getExportedCustomDirectEventTypeConstants() {
62
+ MapBuilder.Builder builder = MapBuilder.builder();
63
+ for (Events event : Events.values()) {
64
+ builder.put(event.toString(), MapBuilder.of("registrationName", event.toString()));
65
+ }
66
+ return builder.build();
67
+ }
68
+
69
+ @Override
70
+ @Nullable
71
+ public Map getExportedViewConstants() {
72
+ return MapBuilder.of(
73
+ "ScaleNone", Integer.toString(ScalableType.LEFT_TOP.ordinal()),
74
+ "ScaleToFill", Integer.toString(ScalableType.FIT_XY.ordinal()),
75
+ "ScaleAspectFit", Integer.toString(ScalableType.FIT_CENTER.ordinal()),
76
+ "ScaleAspectFill", Integer.toString(ScalableType.CENTER_CROP.ordinal())
77
+ );
78
+ }
79
+
80
+ @ReactProp(name = PROP_SRC)
81
+ public void setSrc(final ReactVideoView videoView, @Nullable ReadableMap src) {
82
+ int mainVer = src.getInt(PROP_SRC_MAINVER);
83
+ int patchVer = src.getInt(PROP_SRC_PATCHVER);
84
+ if(mainVer<0) { mainVer = 0; }
85
+ if(patchVer<0) { patchVer = 0; }
86
+ if(mainVer>0) {
87
+ videoView.setSrc(
88
+ src.getString(PROP_SRC_URI),
89
+ src.getString(PROP_SRC_TYPE),
90
+ src.getBoolean(PROP_SRC_IS_NETWORK),
91
+ src.getBoolean(PROP_SRC_IS_ASSET),
92
+ src.getMap(PROP_SRC_HEADERS),
93
+ mainVer,
94
+ patchVer
95
+ );
96
+ }
97
+ else {
98
+ videoView.setSrc(
99
+ src.getString(PROP_SRC_URI),
100
+ src.getString(PROP_SRC_TYPE),
101
+ src.getBoolean(PROP_SRC_IS_NETWORK),
102
+ src.getBoolean(PROP_SRC_IS_ASSET),
103
+ src.getMap(PROP_SRC_HEADERS)
104
+ );
105
+ }
106
+ }
107
+
108
+ @ReactProp(name = PROP_PREVENTS_DISPLAY_SLEEP_DURING_VIDEO_PLAYBACK)
109
+ public void setPropPreventsDisplaySleepDuringVideoPlayback(final ReactVideoView videoView, final boolean doPreventSleep) {
110
+ videoView.setPreventsDisplaySleepDuringVideoPlaybackModifier(doPreventSleep);
111
+ }
112
+
113
+ @ReactProp(name = PROP_RESIZE_MODE)
114
+ public void setResizeMode(final ReactVideoView videoView, final String resizeModeOrdinalString) {
115
+ videoView.setResizeModeModifier(ScalableType.values()[Integer.parseInt(resizeModeOrdinalString)]);
116
+ }
117
+
118
+ @ReactProp(name = PROP_REPEAT, defaultBoolean = false)
119
+ public void setRepeat(final ReactVideoView videoView, final boolean repeat) {
120
+ videoView.setRepeatModifier(repeat);
121
+ }
122
+
123
+ @ReactProp(name = PROP_PAUSED, defaultBoolean = false)
124
+ public void setPaused(final ReactVideoView videoView, final boolean paused) {
125
+ videoView.setPausedModifier(paused);
126
+ }
127
+
128
+ @ReactProp(name = PROP_MUTED, defaultBoolean = false)
129
+ public void setMuted(final ReactVideoView videoView, final boolean muted) {
130
+ videoView.setMutedModifier(muted);
131
+ }
132
+
133
+ @ReactProp(name = PROP_VOLUME, defaultFloat = 1.0f)
134
+ public void setVolume(final ReactVideoView videoView, final float volume) {
135
+ videoView.setVolumeModifier(volume);
136
+ }
137
+
138
+ @ReactProp(name = PROP_STEREO_PAN)
139
+ public void setStereoPan(final ReactVideoView videoView, final float stereoPan) {
140
+ videoView.setStereoPan(stereoPan);
141
+ }
142
+
143
+ @ReactProp(name = PROP_PROGRESS_UPDATE_INTERVAL, defaultFloat = 250.0f)
144
+ public void setProgressUpdateInterval(final ReactVideoView videoView, final float progressUpdateInterval) {
145
+ videoView.setProgressUpdateInterval(progressUpdateInterval);
146
+ }
147
+
148
+ @ReactProp(name = PROP_SEEK)
149
+ public void setSeek(final ReactVideoView videoView, final float seek) {
150
+ videoView.seekTo(Math.round(seek * 1000.0f));
151
+ }
152
+
153
+ @ReactProp(name = PROP_RATE)
154
+ public void setRate(final ReactVideoView videoView, final float rate) {
155
+ videoView.setRateModifier(rate);
156
+ }
157
+
158
+ @ReactProp(name = PROP_FULLSCREEN, defaultBoolean = false)
159
+ public void setFullscreen(final ReactVideoView videoView, final boolean fullscreen) {
160
+ videoView.setFullscreen(fullscreen);
161
+ }
162
+
163
+ @ReactProp(name = PROP_PLAY_IN_BACKGROUND, defaultBoolean = false)
164
+ public void setPlayInBackground(final ReactVideoView videoView, final boolean playInBackground) {
165
+ videoView.setPlayInBackground(playInBackground);
166
+ }
167
+
168
+ @ReactProp(name = PROP_CONTROLS, defaultBoolean = false)
169
+ public void setControls(final ReactVideoView videoView, final boolean controls) {
170
+ videoView.setControls(controls);
171
+ }
172
+ }
@@ -0,0 +1,10 @@
1
+ package com.scalablevideoview;
2
+
3
+ public final class BuildConfig {
4
+ public static final boolean DEBUG = false;
5
+ public static final String LIBRARY_PACKAGE_NAME = "com.yqritc.scalablevideoview";
6
+ public static final String BUILD_TYPE = "release";
7
+
8
+ public BuildConfig() {
9
+ }
10
+ }
@@ -0,0 +1,13 @@
1
+ package com.scalablevideoview;
2
+
3
+ public enum PivotPoint {
4
+ LEFT_TOP,
5
+ LEFT_CENTER,
6
+ LEFT_BOTTOM,
7
+ CENTER_TOP,
8
+ CENTER,
9
+ CENTER_BOTTOM,
10
+ RIGHT_TOP,
11
+ RIGHT_CENTER,
12
+ RIGHT_BOTTOM
13
+ }
@@ -0,0 +1,34 @@
1
+ package com.scalablevideoview;
2
+
3
+ public enum ScalableType {
4
+ NONE,
5
+
6
+ FIT_XY,
7
+ FIT_START,
8
+ FIT_CENTER,
9
+ FIT_END,
10
+
11
+ LEFT_TOP,
12
+ LEFT_CENTER,
13
+ LEFT_BOTTOM,
14
+ CENTER_TOP,
15
+ CENTER,
16
+ CENTER_BOTTOM,
17
+ RIGHT_TOP,
18
+ RIGHT_CENTER,
19
+ RIGHT_BOTTOM,
20
+
21
+ LEFT_TOP_CROP,
22
+ LEFT_CENTER_CROP,
23
+ LEFT_BOTTOM_CROP,
24
+ CENTER_TOP_CROP,
25
+ CENTER_CROP,
26
+ CENTER_BOTTOM_CROP,
27
+ RIGHT_TOP_CROP,
28
+ RIGHT_CENTER_CROP,
29
+ RIGHT_BOTTOM_CROP,
30
+
31
+ START_INSIDE,
32
+ CENTER_INSIDE,
33
+ END_INSIDE
34
+ }
@@ -0,0 +1,255 @@
1
+ package com.scalablevideoview;
2
+
3
+ import android.content.Context;
4
+ import android.content.res.AssetFileDescriptor;
5
+ import android.content.res.AssetManager;
6
+ import android.content.res.TypedArray;
7
+ import android.graphics.Matrix;
8
+ import android.graphics.SurfaceTexture;
9
+ import android.media.MediaPlayer;
10
+ import android.net.Uri;
11
+ import androidx.annotation.NonNull;
12
+ import androidx.annotation.Nullable;
13
+ import androidx.annotation.RawRes;
14
+ import android.util.AttributeSet;
15
+ import android.view.Surface;
16
+ import android.view.TextureView;
17
+
18
+ import com.reactnativecometchatuikit.R;
19
+
20
+ import java.io.FileDescriptor;
21
+ import java.io.IOException;
22
+ import java.util.Map;
23
+
24
+ public class ScalableVideoView extends TextureView implements TextureView.SurfaceTextureListener,
25
+ MediaPlayer.OnVideoSizeChangedListener {
26
+
27
+ protected MediaPlayer mMediaPlayer;
28
+ protected ScalableType mScalableType = ScalableType.NONE;
29
+
30
+ public ScalableVideoView(Context context) {
31
+ this(context, null);
32
+ }
33
+
34
+ public ScalableVideoView(Context context, AttributeSet attrs) {
35
+ this(context, attrs, 0);
36
+ }
37
+
38
+ public ScalableVideoView(Context context, AttributeSet attrs, int defStyle) {
39
+ super(context, attrs, defStyle);
40
+
41
+ if (attrs == null) {
42
+ return;
43
+ }
44
+
45
+ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.scaleStyle, 0, 0);
46
+ if (a == null) {
47
+ return;
48
+ }
49
+
50
+ int scaleType = a.getInt(R.styleable.scaleStyle_scalableType, ScalableType.NONE.ordinal());
51
+ a.recycle();
52
+ mScalableType = ScalableType.values()[scaleType];
53
+ }
54
+
55
+ @Override
56
+ public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) {
57
+ Surface surface = new Surface(surfaceTexture);
58
+ if (mMediaPlayer != null) {
59
+ mMediaPlayer.setSurface(surface);
60
+ }
61
+ }
62
+
63
+ @Override
64
+ public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
65
+ }
66
+
67
+ @Override
68
+ public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
69
+ return false;
70
+ }
71
+
72
+ @Override
73
+ public void onSurfaceTextureUpdated(SurfaceTexture surface) {
74
+ }
75
+
76
+ @Override
77
+ protected void onDetachedFromWindow() {
78
+ super.onDetachedFromWindow();
79
+ if (mMediaPlayer == null) {
80
+ return;
81
+ }
82
+
83
+ if (isPlaying()) {
84
+ stop();
85
+ }
86
+ release();
87
+ }
88
+
89
+ @Override
90
+ public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
91
+ scaleVideoSize(width, height);
92
+ }
93
+
94
+ private void scaleVideoSize(int videoWidth, int videoHeight) {
95
+ if (videoWidth == 0 || videoHeight == 0) {
96
+ return;
97
+ }
98
+
99
+ Size viewSize = new Size(getWidth(), getHeight());
100
+ Size videoSize = new Size(videoWidth, videoHeight);
101
+ ScaleManager scaleManager = new ScaleManager(viewSize, videoSize);
102
+ Matrix matrix = scaleManager.getScaleMatrix(mScalableType);
103
+ if (matrix != null) {
104
+ setTransform(matrix);
105
+ }
106
+ }
107
+
108
+ private void initializeMediaPlayer() {
109
+ if (mMediaPlayer == null) {
110
+ mMediaPlayer = new MediaPlayer();
111
+ mMediaPlayer.setOnVideoSizeChangedListener(this);
112
+ setSurfaceTextureListener(this);
113
+ } else {
114
+ reset();
115
+ }
116
+ }
117
+
118
+ public void setRawData(@RawRes int id) throws IOException {
119
+ AssetFileDescriptor afd = getResources().openRawResourceFd(id);
120
+ setDataSource(afd);
121
+ }
122
+
123
+ public void setAssetData(@NonNull String assetName) throws IOException {
124
+ AssetManager manager = getContext().getAssets();
125
+ AssetFileDescriptor afd = manager.openFd(assetName);
126
+ setDataSource(afd);
127
+ }
128
+
129
+ private void setDataSource(@NonNull AssetFileDescriptor afd) throws IOException {
130
+ setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
131
+ afd.close();
132
+ }
133
+
134
+ public void setDataSource(@NonNull String path) throws IOException {
135
+ initializeMediaPlayer();
136
+ mMediaPlayer.setDataSource(path);
137
+ }
138
+
139
+ public void setDataSource(@NonNull Context context, @NonNull Uri uri,
140
+ @Nullable Map<String, String> headers) throws IOException {
141
+ initializeMediaPlayer();
142
+ mMediaPlayer.setDataSource(context, uri, headers);
143
+ }
144
+
145
+ public void setDataSource(@NonNull Context context, @NonNull Uri uri) throws IOException {
146
+ initializeMediaPlayer();
147
+ mMediaPlayer.setDataSource(context, uri);
148
+ }
149
+
150
+ public void setDataSource(@NonNull FileDescriptor fd, long offset, long length)
151
+ throws IOException {
152
+ initializeMediaPlayer();
153
+ mMediaPlayer.setDataSource(fd, offset, length);
154
+ }
155
+
156
+ public void setDataSource(@NonNull FileDescriptor fd) throws IOException {
157
+ initializeMediaPlayer();
158
+ mMediaPlayer.setDataSource(fd);
159
+ }
160
+
161
+ public void setScalableType(ScalableType scalableType) {
162
+ mScalableType = scalableType;
163
+ scaleVideoSize(getVideoWidth(), getVideoHeight());
164
+ }
165
+
166
+ public void prepare(@Nullable MediaPlayer.OnPreparedListener listener)
167
+ throws IOException, IllegalStateException {
168
+ mMediaPlayer.setOnPreparedListener(listener);
169
+ mMediaPlayer.prepare();
170
+ }
171
+
172
+ public void prepareAsync(@Nullable MediaPlayer.OnPreparedListener listener)
173
+ throws IllegalStateException {
174
+ mMediaPlayer.setOnPreparedListener(listener);
175
+ mMediaPlayer.prepareAsync();
176
+ }
177
+
178
+ public void prepare() throws IOException, IllegalStateException {
179
+ prepare(null);
180
+ }
181
+
182
+ public void prepareAsync() throws IllegalStateException {
183
+ prepareAsync(null);
184
+ }
185
+
186
+ public void setOnErrorListener(@Nullable MediaPlayer.OnErrorListener listener) {
187
+ mMediaPlayer.setOnErrorListener(listener);
188
+ }
189
+
190
+ public void setOnCompletionListener(@Nullable MediaPlayer.OnCompletionListener listener) {
191
+ mMediaPlayer.setOnCompletionListener(listener);
192
+ }
193
+
194
+ public void setOnInfoListener(@Nullable MediaPlayer.OnInfoListener listener) {
195
+ mMediaPlayer.setOnInfoListener(listener);
196
+ }
197
+
198
+ public int getCurrentPosition() {
199
+ return mMediaPlayer.getCurrentPosition();
200
+ }
201
+
202
+ public int getDuration() {
203
+ return mMediaPlayer.getDuration();
204
+ }
205
+
206
+ public int getVideoHeight() {
207
+ return mMediaPlayer.getVideoHeight();
208
+ }
209
+
210
+ public int getVideoWidth() {
211
+ return mMediaPlayer.getVideoWidth();
212
+ }
213
+
214
+ public boolean isLooping() {
215
+ return mMediaPlayer.isLooping();
216
+ }
217
+
218
+ public boolean isPlaying() {
219
+ return mMediaPlayer.isPlaying();
220
+ }
221
+
222
+ public void pause() {
223
+ mMediaPlayer.pause();
224
+ }
225
+
226
+ public void seekTo(int msec) {
227
+ mMediaPlayer.seekTo(msec);
228
+ }
229
+
230
+ public void setLooping(boolean looping) {
231
+ mMediaPlayer.setLooping(looping);
232
+ }
233
+
234
+ public void setVolume(float leftVolume, float rightVolume) {
235
+ mMediaPlayer.setVolume(leftVolume, rightVolume);
236
+ }
237
+
238
+ public void start() {
239
+ mMediaPlayer.start();
240
+ }
241
+
242
+ public void stop() {
243
+ mMediaPlayer.stop();
244
+ }
245
+
246
+ public void reset() {
247
+ mMediaPlayer.reset();
248
+ }
249
+
250
+ public void release() {
251
+ reset();
252
+ mMediaPlayer.release();
253
+ mMediaPlayer = null;
254
+ }
255
+ }
@@ -0,0 +1,188 @@
1
+ package com.scalablevideoview;
2
+
3
+ import android.graphics.Matrix;
4
+
5
+ public class ScaleManager {
6
+
7
+ private Size mViewSize;
8
+ private Size mVideoSize;
9
+
10
+ public ScaleManager(Size viewSize, Size videoSize) {
11
+ mViewSize = viewSize;
12
+ mVideoSize = videoSize;
13
+ }
14
+
15
+ public Matrix getScaleMatrix(ScalableType scalableType) {
16
+ switch (scalableType) {
17
+ case NONE:
18
+ return getNoScale();
19
+
20
+ case FIT_XY:
21
+ return fitXY();
22
+ case FIT_CENTER:
23
+ return fitCenter();
24
+ case FIT_START:
25
+ return fitStart();
26
+ case FIT_END:
27
+ return fitEnd();
28
+
29
+ case LEFT_TOP:
30
+ return getOriginalScale(PivotPoint.LEFT_TOP);
31
+ case LEFT_CENTER:
32
+ return getOriginalScale(PivotPoint.LEFT_CENTER);
33
+ case LEFT_BOTTOM:
34
+ return getOriginalScale(PivotPoint.LEFT_BOTTOM);
35
+ case CENTER_TOP:
36
+ return getOriginalScale(PivotPoint.CENTER_TOP);
37
+ case CENTER:
38
+ return getOriginalScale(PivotPoint.CENTER);
39
+ case CENTER_BOTTOM:
40
+ return getOriginalScale(PivotPoint.CENTER_BOTTOM);
41
+ case RIGHT_TOP:
42
+ return getOriginalScale(PivotPoint.RIGHT_TOP);
43
+ case RIGHT_CENTER:
44
+ return getOriginalScale(PivotPoint.RIGHT_CENTER);
45
+ case RIGHT_BOTTOM:
46
+ return getOriginalScale(PivotPoint.RIGHT_BOTTOM);
47
+
48
+ case LEFT_TOP_CROP:
49
+ return getCropScale(PivotPoint.LEFT_TOP);
50
+ case LEFT_CENTER_CROP:
51
+ return getCropScale(PivotPoint.LEFT_CENTER);
52
+ case LEFT_BOTTOM_CROP:
53
+ return getCropScale(PivotPoint.LEFT_BOTTOM);
54
+ case CENTER_TOP_CROP:
55
+ return getCropScale(PivotPoint.CENTER_TOP);
56
+ case CENTER_CROP:
57
+ return getCropScale(PivotPoint.CENTER);
58
+ case CENTER_BOTTOM_CROP:
59
+ return getCropScale(PivotPoint.CENTER_BOTTOM);
60
+ case RIGHT_TOP_CROP:
61
+ return getCropScale(PivotPoint.RIGHT_TOP);
62
+ case RIGHT_CENTER_CROP:
63
+ return getCropScale(PivotPoint.RIGHT_CENTER);
64
+ case RIGHT_BOTTOM_CROP:
65
+ return getCropScale(PivotPoint.RIGHT_BOTTOM);
66
+
67
+ case START_INSIDE:
68
+ return startInside();
69
+ case CENTER_INSIDE:
70
+ return centerInside();
71
+ case END_INSIDE:
72
+ return endInside();
73
+
74
+ default:
75
+ return null;
76
+ }
77
+ }
78
+
79
+ private Matrix getMatrix(float sx, float sy, float px, float py) {
80
+ Matrix matrix = new Matrix();
81
+ matrix.setScale(sx, sy, px, py);
82
+ return matrix;
83
+ }
84
+
85
+ private Matrix getMatrix(float sx, float sy, PivotPoint pivotPoint) {
86
+ switch (pivotPoint) {
87
+ case LEFT_TOP:
88
+ return getMatrix(sx, sy, 0, 0);
89
+ case LEFT_CENTER:
90
+ return getMatrix(sx, sy, 0, mViewSize.getHeight() / 2f);
91
+ case LEFT_BOTTOM:
92
+ return getMatrix(sx, sy, 0, mViewSize.getHeight());
93
+ case CENTER_TOP:
94
+ return getMatrix(sx, sy, mViewSize.getWidth() / 2f, 0);
95
+ case CENTER:
96
+ return getMatrix(sx, sy, mViewSize.getWidth() / 2f, mViewSize.getHeight() / 2f);
97
+ case CENTER_BOTTOM:
98
+ return getMatrix(sx, sy, mViewSize.getWidth() / 2f, mViewSize.getHeight());
99
+ case RIGHT_TOP:
100
+ return getMatrix(sx, sy, mViewSize.getWidth(), 0);
101
+ case RIGHT_CENTER:
102
+ return getMatrix(sx, sy, mViewSize.getWidth(), mViewSize.getHeight() / 2f);
103
+ case RIGHT_BOTTOM:
104
+ return getMatrix(sx, sy, mViewSize.getWidth(), mViewSize.getHeight());
105
+ default:
106
+ throw new IllegalArgumentException("Illegal PivotPoint");
107
+ }
108
+ }
109
+
110
+ private Matrix getNoScale() {
111
+ float sx = mVideoSize.getWidth() / (float) mViewSize.getWidth();
112
+ float sy = mVideoSize.getHeight() / (float) mViewSize.getHeight();
113
+ return getMatrix(sx, sy, PivotPoint.LEFT_TOP);
114
+ }
115
+
116
+ private Matrix getFitScale(PivotPoint pivotPoint) {
117
+ float sx = (float) mViewSize.getWidth() / mVideoSize.getWidth();
118
+ float sy = (float) mViewSize.getHeight() / mVideoSize.getHeight();
119
+ float minScale = Math.min(sx, sy);
120
+ sx = minScale / sx;
121
+ sy = minScale / sy;
122
+ return getMatrix(sx, sy, pivotPoint);
123
+ }
124
+
125
+ private Matrix fitXY() {
126
+ return getMatrix(1, 1, PivotPoint.LEFT_TOP);
127
+ }
128
+
129
+ private Matrix fitStart() {
130
+ return getFitScale(PivotPoint.LEFT_TOP);
131
+ }
132
+
133
+ private Matrix fitCenter() {
134
+ return getFitScale(PivotPoint.CENTER);
135
+ }
136
+
137
+ private Matrix fitEnd() {
138
+ return getFitScale(PivotPoint.RIGHT_BOTTOM);
139
+ }
140
+
141
+ private Matrix getOriginalScale(PivotPoint pivotPoint) {
142
+ float sx = mVideoSize.getWidth() / (float) mViewSize.getWidth();
143
+ float sy = mVideoSize.getHeight() / (float) mViewSize.getHeight();
144
+ return getMatrix(sx, sy, pivotPoint);
145
+ }
146
+
147
+ private Matrix getCropScale(PivotPoint pivotPoint) {
148
+ float sx = (float) mViewSize.getWidth() / mVideoSize.getWidth();
149
+ float sy = (float) mViewSize.getHeight() / mVideoSize.getHeight();
150
+ float maxScale = Math.max(sx, sy);
151
+ sx = maxScale / sx;
152
+ sy = maxScale / sy;
153
+ return getMatrix(sx, sy, pivotPoint);
154
+ }
155
+
156
+ private Matrix startInside() {
157
+ if (mVideoSize.getHeight() <= mViewSize.getWidth()
158
+ && mVideoSize.getHeight() <= mViewSize.getHeight()) {
159
+ // video is smaller than view size
160
+ return getOriginalScale(PivotPoint.LEFT_TOP);
161
+ } else {
162
+ // either of width or height of the video is larger than view size
163
+ return fitStart();
164
+ }
165
+ }
166
+
167
+ private Matrix centerInside() {
168
+ if (mVideoSize.getHeight() <= mViewSize.getWidth()
169
+ && mVideoSize.getHeight() <= mViewSize.getHeight()) {
170
+ // video is smaller than view size
171
+ return getOriginalScale(PivotPoint.CENTER);
172
+ } else {
173
+ // either of width or height of the video is larger than view size
174
+ return fitCenter();
175
+ }
176
+ }
177
+
178
+ private Matrix endInside() {
179
+ if (mVideoSize.getHeight() <= mViewSize.getWidth()
180
+ && mVideoSize.getHeight() <= mViewSize.getHeight()) {
181
+ // video is smaller than view size
182
+ return getOriginalScale(PivotPoint.RIGHT_BOTTOM);
183
+ } else {
184
+ // either of width or height of the video is larger than view size
185
+ return fitEnd();
186
+ }
187
+ }
188
+ }
@@ -0,0 +1,20 @@
1
+ package com.scalablevideoview;
2
+
3
+ public class Size {
4
+
5
+ private int mWidth;
6
+ private int mHeight;
7
+
8
+ public Size(int width, int height) {
9
+ mWidth = width;
10
+ mHeight = height;
11
+ }
12
+
13
+ public int getWidth() {
14
+ return mWidth;
15
+ }
16
+
17
+ public int getHeight() {
18
+ return mHeight;
19
+ }
20
+ }