Skip to content

Commit

Permalink
fix to work with fabric interop
Browse files Browse the repository at this point in the history
  • Loading branch information
joemun committed Jul 13, 2023
1 parent 38efd95 commit 4baa987
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Video.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export default class Video extends Component {
const isAsset = !!(uri && uri.match(/^(assets-library|ipod-library|file|content|ms-appx|ms-appdata):/));

let nativeResizeMode;
const RCTVideoInstance = this.getViewManagerConfig('RCTVideo');
const RCTVideoInstance = this.getViewManagerConfig('RNVVideo');

if (resizeMode === VideoResizeMode.stretch) {
nativeResizeMode = RCTVideoInstance.Constants.ScaleToFill;
Expand Down Expand Up @@ -510,7 +510,7 @@ Video.propTypes = {
...ViewPropTypes,
};

const RCTVideo = requireNativeComponent('RCTVideo', Video, {
const RCTVideo = requireNativeComponent('RNVVideo', Video, {
nativeOnly: {
src: true,
seek: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReadableMapKeySetIterator;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.ViewGroupManager;
import com.facebook.react.uimanager.annotations.ReactProp;
Expand All @@ -27,7 +28,7 @@

public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerView> {

private static final String REACT_CLASS = "RCTVideo";
private static final String REACT_CLASS = "RNVVideo";

private static final String PROP_SRC = "src";
private static final String PROP_SRC_URI = "uri";
Expand Down Expand Up @@ -96,7 +97,10 @@ public void onDropViewInstance(ReactExoplayerView view) {
public @Nullable Map<String, Object> getExportedCustomDirectEventTypeConstants() {
MapBuilder.Builder<String, Object> builder = MapBuilder.builder();
for (String event : VideoEventEmitter.Events) {
builder.put(event, MapBuilder.of("registrationName", event));
String eventKey = ReactFeatureFlags.enableFabricRenderer ?
"top" + event.substring(0, 1).toUpperCase() + event.substring(1) :
event;
builder.put(eventKey, MapBuilder.of("registrationName", event));
}
return builder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,6 @@ void audioBecomingNoisy() {
}

private void receiveEvent(@VideoEvents String type, WritableMap event) {
eventEmitter.receiveEvent(viewId, type, event);
eventEmitter.receiveEvent(viewId, type, event != null ? event : Arguments.createMap());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

public class ReactVideoViewManager extends SimpleViewManager<ReactVideoView> {

public static final String REACT_CLASS = "RCTVideo";
public static final String REACT_CLASS = "RNVVideo";

public static final String PROP_SRC = "src";
public static final String PROP_SRC_URI = "uri";
Expand Down
9 changes: 9 additions & 0 deletions examples/fabric/react-native.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
module.exports = {
project: {
android: {
unstable_reactLegacyComponentNames: ['RNVVideo'],
},
ios: {
unstable_reactLegacyComponentNames: [],
},
},

dependencies: {
'react-native-video': {
platforms: {
Expand Down
2 changes: 1 addition & 1 deletion ios/Video/RCTVideoManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

@implementation RCTVideoManager

RCT_EXPORT_MODULE();
RCT_EXPORT_MODULE(RNVVideoManager);

- (UIView *)view
{
Expand Down

0 comments on commit 4baa987

Please sign in to comment.