首页 > 解决方案 > 为 react-native-video-controls 添加 TouchableOpacity

问题描述

全部,

我们正在开发一个具有视频功能的 react-native 应用程序,并且我们正在使用 react-native-video-controls 模块来处理它。

一个用例是我们必须在网格中显示视频文件,当我们单击每个项目时,它应该像在什么应用程序中一样以完整模式播放。

我们可以在手柄中调整视频播放器的大小并设置播放按钮吗?因此,当单击播放按钮时,它应该以完整模式打开。

无法实现 Button 视频。

  <VideoPlayer 
    onPress={()=> { this.props.playMedia(this.props.content) }} 
    source={{ uri: this.props.content }} 
    disableVolume 
    disableFullscreen
    paused={true} 
    fullscreen={false} 
    disableSeekbar 
    disableVolume 
    disableTimer 
    disableBack 
    onPlay={() => { this.props.playMedia(this.props.content) }} >
         {/* <TouchableOpacity 
               onPress={() => { console.log(this.props.content); 
                          this.props.playMedia(this.props.content) 
                        }} >
             </TouchableOpacity> 
          */}
</VideoPlayer>

标签: androidiosreact-nativevideo-player

解决方案


您可以创建具有绝对定位的可触摸不透明度,而不是通过更改 VideoPlayer 中的“暂停”道具值来播放视频


推荐阅读