use react native asset resolving
This commit is contained in:
parent
5221c948d5
commit
7fc7b3dc1b
41
Video.js
41
Video.js
@ -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',
|
||||||
@ -149,10 +138,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(/^\//)) {
|
||||||
@ -215,7 +202,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,
|
||||||
@ -242,11 +235,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,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user