video working

This commit is contained in:
Diego Mello 2017-11-27 19:43:26 -02:00
parent 0289e799eb
commit a1800a602b
4 changed files with 5 additions and 56 deletions

View File

@ -29,8 +29,6 @@ export default class Video extends React.PureComponent {
modalVisible: false, modalVisible: false,
uri: `${ server }${ file.video_url }?rc_uid=${ user.id }&rc_token=${ user.token }` uri: `${ server }${ file.video_url }?rc_uid=${ user.id }&rc_token=${ user.token }`
}; };
// this.setState({ img: `${ this.props.base }${ this.props.data.image_url }?rc_uid=${ user._id }&rc_token=${ token }` });
console.warn(this.state.uri)
} }
toggleModal() { toggleModal() {

View File

@ -1,13 +1,7 @@
import React from 'react'; import React from 'react';
import { Text } from 'react-native';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import Modal from 'react-native-modal'; import Modal from 'react-native-modal';
import VideoPlayer from 'react-native-video-controls'; import VideoPlayer from 'react-native-video-controls';
import Video from 'react-native-video';
import RocketChat from '../../lib/rocketchat';
import { connect } from 'react-redux';
import { setToken } from '../../actions/login';
const styles = { const styles = {
@ -16,21 +10,8 @@ const styles = {
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
backgroundColor: '#000' backgroundColor: '#000'
}, backgroundVideo: { }
position: 'absolute',
top: 0,
left: 0,
bottom: 0,
right: 0,
},
}; };
@connect(state => ({
server: state.server.server,
user: state.login.user
}), dispatch => ({
setToken: token => dispatch(setToken(token))
}))
export default class extends React.PureComponent { export default class extends React.PureComponent {
static propTypes = { static propTypes = {
uri: PropTypes.string.isRequired, uri: PropTypes.string.isRequired,
@ -38,32 +19,12 @@ export default class extends React.PureComponent {
onClose: PropTypes.func.isRequired onClose: PropTypes.func.isRequired
} }
constructor(props) {
super(props);
this.state = {
uri: '',
loading: true
};
}
async componentWillMount() {
const newUri = await RocketChat.resolveFile(this.props.uri);
console.warn(newUri);
this.setState({ uri: newUri, loading: false });
// this.props.setToken({token: newUri});
}
renderVideo() { renderVideo() {
if (this.state.loading) {
return <Text style={{ color: '#fff' }}>Loading...</Text>;
}
return ( return (
<Video <VideoPlayer
source={{ uri: this.props.uri }} source={{ uri: this.props.uri }}
style={styles.backgroundVideo} onBack={this.props.onClose}
// onBack={this.props.onClose} disableVolume
// disableVolume
/> />
); );
} }

View File

@ -26,16 +26,6 @@ const TOKEN_KEY = 'reactnativemeteor_usertoken';
const RocketChat = { const RocketChat = {
TOKEN_KEY, TOKEN_KEY,
async resolveFile(url) {
const response = await fetch(url, {
method: 'GET',
mode: 'cors',
redirect: 'nofollow',
cache: 'default'
});
return response.url.toString();
},
createChannel({ name, users, type }) { createChannel({ name, users, type }) {
return call(type ? 'createChannel' : 'createPrivateGroup', name, users, type); return call(type ? 'createChannel' : 'createPrivateGroup', name, users, type);
}, },

View File

@ -216,7 +216,7 @@ export default class RoomView extends React.Component {
/> />
</SafeAreaView> </SafeAreaView>
{this.renderFooter()} {this.renderFooter()}
{/* <MessageActions room={this.room} /> */} <MessageActions room={this.room} />
</KeyboardView> </KeyboardView>
); );
} }