首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >react-native-gifted-chat视频消息不显示-Video not by GiftedChat implemented

react-native-gifted-chat视频消息不显示-Video not by GiftedChat implemented
EN

Stack Overflow用户
提问于 2020-05-14 00:56:16
回答 1查看 2.1K关注 0票数 1

消息中未显示视频。收到消息“视频不是GiftedChat实现的,您需要通过renderMessageVideo prop提供自己的实现。

代码语言:javascript
复制
Message[] has the following values:
_id:
text: 
createdAt:
user:{
       _id:
       name:
       avatar:
     },
     image: 
     video:


<GiftedChat
messages={this.state.messages}
onSend={this.onSend.bind(this)}
user={{
_id: this.state.LoggedinuserID,
}}
/>

请帮帮我,我哪里做错了?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-05-16 00:16:49

这是什么意思,您需要提供自定义组件来包装视频

在您的示例中,您将消息直接呈现给GiftedChat,因此我们将把自定义视频组件传递给GiftedChat,如下所示

参考:https://github.com/FaridSafi/react-native-gifted-chat/#react-native-video-and-expo-av

代码语言:javascript
复制
import { Video,Audio } from 'expo-av';

   const renderMessageVideo = (props: any) => {
     const { currentMessage } = props;
     return (
       <View style={{ padding: 20 }}>
          <Video
           resizeMode="contain"
           useNativeControls
           shouldPlay={false}
           source={{ uri: currentMessage.video }}
           style={styles.video}
         />
       </View>
     );
   };


<GiftedChat
messages={this.state.messages}
onSend={this.onSend.bind(this)}
renderMessageVideo={renderMessageVideo}
user={{
_id: this.state.LoggedinuserID,
}}
/>
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61780438

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档