use react native asset resolving

This commit is contained in:
Mark Oswald 2016-06-22 15:52:12 +02:00
parent 5221c948d5
commit 7fc7b3dc1b
No known key found for this signature in database
GPG Key ID: 0B2306A7A002CFA4

View File

@ -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,
};