Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replaced UIManager.RCTVideo > UIManager.getViewManagerConfig('RCTVideo') #1487

Merged
merged 4 commits into from
Feb 18, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "airbnb",
"parser": "babel-eslint"
}
}
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Changelog

### next

* replaced UIManager.RCTVideo > UIManager.getViewManagerConfig('RCTVideo') [#1487](https://github.com/react-native-community/react-native-video/pull/1487)
* Fix loading package resolved videos when using video-caching [#1438](https://github.com/react-native-community/react-native-video/pull/1438)
* Fix "message sent to deallocated instance" crash on ios [#1482](https://github.com/react-native-community/react-native-video/pull/1482)

Expand Down
17 changes: 13 additions & 4 deletions Video.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ export default class Video extends Component {
}
};

getViewManagerConfig = viewManagerName => {
if (!UIManager.getViewManagerConfig) {
return UIManager[viewManagerName];
}
return UIManager.getViewManagerConfig(viewManagerName);
};

render() {
const resizeMode = this.props.resizeMode;
const source = resolveAssetSource(this.props.source) || {};
Expand All @@ -224,14 +231,16 @@ 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');

if (resizeMode === VideoResizeMode.stretch) {
nativeResizeMode = NativeModules.UIManager.RCTVideo.Constants.ScaleToFill;
nativeResizeMode = RCTVideoInstance.Constants.ScaleToFill;
} else if (resizeMode === VideoResizeMode.contain) {
nativeResizeMode = NativeModules.UIManager.RCTVideo.Constants.ScaleAspectFit;
nativeResizeMode = RCTVideoInstance.Constants.ScaleAspectFit;
} else if (resizeMode === VideoResizeMode.cover) {
nativeResizeMode = NativeModules.UIManager.RCTVideo.Constants.ScaleAspectFill;
nativeResizeMode = RCTVideoInstance.Constants.ScaleAspectFill;
} else {
nativeResizeMode = NativeModules.UIManager.RCTVideo.Constants.ScaleNone;
nativeResizeMode = RCTVideoInstance.Constants.ScaleNone;
}

const nativeProps = Object.assign({}, this.props);
Expand Down