From 7fc7b3dc1ba20bd0b42e47ffe0bbb3f74d696bac Mon Sep 17 00:00:00 2001 From: Mark Oswald Date: Wed, 22 Jun 2016 15:52:12 +0200 Subject: [PATCH] use react native asset resolving --- Video.js | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/Video.js b/Video.js index 185c4d0d..126a427d 100644 --- a/Video.js +++ b/Video.js @@ -1,19 +1,8 @@ -import React from 'react'; -import ReactNative from 'react-native'; +import React, {Component, PropTypes} from 'react'; +import {StyleSheet, requireNativeComponent, NativeModules, View} from 'react-native'; +import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource'; import VideoResizeMode from './VideoResizeMode.js'; -const { - Component, - PropTypes, -} = React; - -const { - StyleSheet, - requireNativeComponent, - NativeModules, - View, -} = ReactNative; - const styles = StyleSheet.create({ base: { overflow: 'hidden', @@ -149,10 +138,8 @@ export default class Video extends Component { } render() { - const { - source, - resizeMode, - } = this.props; + const resizeMode = this.props.resizeMode; + const source = resolveAssetSource(this.props.source) || {}; let uri = source.uri; if (uri && uri.match(/^\//)) { @@ -215,7 +202,13 @@ Video.propTypes = { fullscreen: PropTypes.bool, /* Wrapper component */ - source: PropTypes.object, + source: PropTypes.oneOfType([ + PropTypes.shape({ + uri: PropTypes.string + }), + // Opaque type returned by require('./video.mp4') + PropTypes.number + ]), resizeMode: PropTypes.string, repeat: PropTypes.bool, paused: PropTypes.bool, @@ -242,11 +235,11 @@ Video.propTypes = { onPlaybackRateChange: PropTypes.func, /* Required by react-native */ - scaleX: React.PropTypes.number, - scaleY: React.PropTypes.number, - translateX: React.PropTypes.number, - translateY: React.PropTypes.number, - rotation: React.PropTypes.number, + scaleX: PropTypes.number, + scaleY: PropTypes.number, + translateX: PropTypes.number, + translateY: PropTypes.number, + rotation: PropTypes.number, ...View.propTypes, };