On react-native-gifted-chat
main page, there is an example of message object with text, image and video all together:
{
_id: 1,
text: 'My message',
createdAt: new Date(Date.UTC(2016, 5, 11, 17, 20, 0)),
user: {
_id: 2,
name: 'React Native',
avatar: 'https://facebook.github.io/react/img/logo_og.png',
},
image: 'https://facebook.github.io/react/img/logo_og.png',
// You can also add a video prop:
video: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4',
// Any additional custom parameters are passed through
}
here is the code which works fine rendering text message:
render() {
return (
<GiftedChat
messages={this.state.messages}
onSend={messages => this._onSend(messages)}
user={{_id: this.props.navigation.state.params.user.id,
name: this.props.navigation.state.params.user.name,
avatar: this.props.navigation.state.params.user.user_data.avatar}}
/>
);
}
I added both image
and video
to the message data:
r = {
_id: '',
text: '',
image:"",
video:"",
createdAt : '',
user: {
_id: '',
name: '',
avatar: ''
}
};
and created a message with video
equal to a string of http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4
. But the video is not shown in chat screen and therefore I can't click and play this video. What is missing with the code above to show a video (image) in gifted chat? Do I need to enable certain props for video or image?