react-native - React-Native-Video 在模态框内使用时不显示控件
问题描述
在我的 RN 应用程序中,我使用 react-native-video。在屏幕内使用时,它可以正常工作。控件可见。但是当我在模式中尝试它时,视频可以工作,但控件没有显示。
这是代码。
视频播放器组件。
import React from 'react';
import { StyleSheet } from 'react-native';
import Video, { LoadError } from 'react-native-video';
import Logger from 'library/logger';
// import { toggleSpinner } from 'Redux/common/common.actions';
import { store } from 'store';
const VideoPlayer = ({ source, ...otherProps }: IProps) => {
const handleError = (error: LoadError) => {
Logger.log('VIDEO_LOADING_ERROR', 'Error occured while loading the video', error);
};
const onLoadStart = () => {
// store.dispatch(toggleSpinner(true));
};
const onLoadEnd = () => {
// store.dispatch(toggleSpinner(false));
};
return (
<Video
source={{ uri: source }}
controls={true}
repeat={otherProps.repeat}
onLoadStart={onLoadStart}
onReadyForDisplay={onLoadEnd}
resizeMode={otherProps.videoResizeMode}
onError={(error: LoadError) => handleError(error)}
style={styles.videoPlayer}
/>
);
};
const styles = StyleSheet.create({
videoPlayer: {
top: 0,
left: 0,
bottom: 0,
right: 0,
height: 300,
},
});
interface IProps {
controls: boolean;
source: string;
repeat: false;
videoResizeMode: 'stretch' | 'contain' | 'cover' | 'none' | undefined;
}
VideoPlayer.defaultProps = {
videoResizeMode: 'stretch',
repeat: true,
controls: true,
};
export default VideoPlayer;
模态的。
const VideoModal = ({ active, data, onClose }: IProps) => (
<Modal
visible={active}
// fullScreen={true}
// animationType='slide'
onRequestClose={() => onClose()}>
{/* <View style={styles.modalContentContainer}> */}
<VideoPlayer source={data.source} />
{/* </View> */}
</Modal>
);
像这样调用模态。
<VideoModal
active={videoModalActive}
data={{
source:
'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
// 'file:///storage/emulated/0/Movies/campaignVideo.mp4',
}}
onClose={toggleVideoModal}
/>
为什么控件仅在模式上运行时才隐藏?
解决方案
推荐阅读
- .net - 将 GIF 图像添加到 resources.rc 后,Visual Studio 会破坏它
- ssas - MDX 中的命名集与“分组集”
- r - R组合来自不同小标题的数据
- git - git clone 函数的哪个部分需要更长的时间?- “接收对象”或“解决增量”
- python - R/Python,如何在不使用简单 for 循环的情况下根据 2 个条件填充数据?
- java - 构建失败错误:如果 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) 找不到符号
- python - “未分配指针被释放”错误使用 cython 与基于 FFTW 的外部 c 库并行
- r - 用于混合模型的 Gibbs 采样器中的 NA 错误
- floating-point - PyTorch 给了我一个不同的标量值
- python-3.x - 当我从 Python 中的谷歌搜索查询中提取链接时,我无法返回 HTML 链接