Merge pull request #251 from mroswald/feat/play-react-native-assets

use react native asset resolving
This commit is contained in:
Brent Vatne 2016-08-15 18:13:41 -07:00 committed by GitHub
commit 6f969a8614

View File

@ -1,19 +1,8 @@
import React from 'react'; import React, {Component, PropTypes} from 'react';
import ReactNative from 'react-native'; import {StyleSheet, requireNativeComponent, NativeModules, View} from 'react-native';
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
import VideoResizeMode from './VideoResizeMode.js'; import VideoResizeMode from './VideoResizeMode.js';
const {
Component,
PropTypes,
} = React;
const {
StyleSheet,
requireNativeComponent,
NativeModules,
View,
} = ReactNative;
const styles = StyleSheet.create({ const styles = StyleSheet.create({
base: { base: {
overflow: 'hidden', overflow: 'hidden',
@ -127,10 +116,8 @@ export default class Video extends Component {
}; };
render() { render() {
const { const resizeMode = this.props.resizeMode;
source, const source = resolveAssetSource(this.props.source) || {};
resizeMode,
} = this.props;
let uri = source.uri; let uri = source.uri;
if (uri && uri.match(/^\//)) { if (uri && uri.match(/^\//)) {
@ -193,7 +180,13 @@ Video.propTypes = {
fullscreen: PropTypes.bool, fullscreen: PropTypes.bool,
/* Wrapper component */ /* 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, resizeMode: PropTypes.string,
repeat: PropTypes.bool, repeat: PropTypes.bool,
paused: PropTypes.bool, paused: PropTypes.bool,
@ -220,11 +213,11 @@ Video.propTypes = {
onPlaybackRateChange: PropTypes.func, onPlaybackRateChange: PropTypes.func,
/* Required by react-native */ /* Required by react-native */
scaleX: React.PropTypes.number, scaleX: PropTypes.number,
scaleY: React.PropTypes.number, scaleY: PropTypes.number,
translateX: React.PropTypes.number, translateX: PropTypes.number,
translateY: React.PropTypes.number, translateY: PropTypes.number,
rotation: React.PropTypes.number, rotation: PropTypes.number,
...View.propTypes, ...View.propTypes,
}; };