Skip to content

Commit 4baa987

Browse files
committed
fix to work with fabric interop
1 parent 38efd95 commit 4baa987

File tree

6 files changed

+20
-7
lines changed

6 files changed

+20
-7
lines changed

Video.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ export default class Video extends Component {
279279
const isAsset = !!(uri && uri.match(/^(assets-library|ipod-library|file|content|ms-appx|ms-appdata):/));
280280

281281
let nativeResizeMode;
282-
const RCTVideoInstance = this.getViewManagerConfig('RCTVideo');
282+
const RCTVideoInstance = this.getViewManagerConfig('RNVVideo');
283283

284284
if (resizeMode === VideoResizeMode.stretch) {
285285
nativeResizeMode = RCTVideoInstance.Constants.ScaleToFill;
@@ -510,7 +510,7 @@ Video.propTypes = {
510510
...ViewPropTypes,
511511
};
512512

513-
const RCTVideo = requireNativeComponent('RCTVideo', Video, {
513+
const RCTVideo = requireNativeComponent('RNVVideo', Video, {
514514
nativeOnly: {
515515
src: true,
516516
seek: true,

android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.facebook.react.bridge.ReadableMap;
1111
import com.facebook.react.bridge.ReadableMapKeySetIterator;
1212
import com.facebook.react.common.MapBuilder;
13+
import com.facebook.react.config.ReactFeatureFlags;
1314
import com.facebook.react.uimanager.ThemedReactContext;
1415
import com.facebook.react.uimanager.ViewGroupManager;
1516
import com.facebook.react.uimanager.annotations.ReactProp;
@@ -27,7 +28,7 @@
2728

2829
public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerView> {
2930

30-
private static final String REACT_CLASS = "RCTVideo";
31+
private static final String REACT_CLASS = "RNVVideo";
3132

3233
private static final String PROP_SRC = "src";
3334
private static final String PROP_SRC_URI = "uri";
@@ -96,7 +97,10 @@ public void onDropViewInstance(ReactExoplayerView view) {
9697
public @Nullable Map<String, Object> getExportedCustomDirectEventTypeConstants() {
9798
MapBuilder.Builder<String, Object> builder = MapBuilder.builder();
9899
for (String event : VideoEventEmitter.Events) {
99-
builder.put(event, MapBuilder.of("registrationName", event));
100+
String eventKey = ReactFeatureFlags.enableFabricRenderer ?
101+
"top" + event.substring(0, 1).toUpperCase() + event.substring(1) :
102+
event;
103+
builder.put(eventKey, MapBuilder.of("registrationName", event));
100104
}
101105
return builder.build();
102106
}

android-exoplayer/src/main/java/com/brentvatne/exoplayer/VideoEventEmitter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,6 @@ void audioBecomingNoisy() {
299299
}
300300

301301
private void receiveEvent(@VideoEvents String type, WritableMap event) {
302-
eventEmitter.receiveEvent(viewId, type, event);
302+
eventEmitter.receiveEvent(viewId, type, event != null ? event : Arguments.createMap());
303303
}
304304
}

android/src/main/java/com/brentvatne/react/ReactVideoViewManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
public class ReactVideoViewManager extends SimpleViewManager<ReactVideoView> {
1818

19-
public static final String REACT_CLASS = "RCTVideo";
19+
public static final String REACT_CLASS = "RNVVideo";
2020

2121
public static final String PROP_SRC = "src";
2222
public static final String PROP_SRC_URI = "uri";

examples/fabric/react-native.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
module.exports = {
2+
project: {
3+
android: {
4+
unstable_reactLegacyComponentNames: ['RNVVideo'],
5+
},
6+
ios: {
7+
unstable_reactLegacyComponentNames: [],
8+
},
9+
},
10+
211
dependencies: {
312
'react-native-video': {
413
platforms: {

ios/Video/RCTVideoManager.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
@implementation RCTVideoManager
88

9-
RCT_EXPORT_MODULE();
9+
RCT_EXPORT_MODULE(RNVVideoManager);
1010

1111
- (UIView *)view
1212
{

0 commit comments

Comments
 (0)