react-native - 使用视频的第一帧作为缩略图
问题描述
我正在使用react-native-video
它有一个名为的道具poster
,它工作正常。但我的要求是从视频(视频的第一帧)中获取该缩略图。如果我不使用poster
(接受 url),那么它会显示空白屏幕。
知道如何将视频的第一帧用作缩略图吗?
谢谢你!!!
解决方案
您可以使用onLoad
函数回调来实现它,
const player = useRef(null);
<Video
source={{uri: uri}}
ref={player}
paused={true}
style={styles.backgroundVideo}
onLoad={() => {
player.current.seek(0); // this will set first frame of video as thumbnail
}}
/>
有关onLoad
道具的更多详细信息:这里
推荐阅读
- javascript - 如何从对象数组中提取元素来实现对象?
- arduino - Arduino Mega 和 Arduino Nano 之间的串行通信
- vue.js - 在页面重新加载/刷新时属性设置为未定义
- testing - 需要将 AzureDevOps 中的手动测试运行执行结果导出为任何格式
- regex - 删除旧文件并将最新文件保留在 Linux 目录中的脚本
- git - 如何在存储库中删除这种“符号链接”之类的东西?
- firefox - Ubuntu 18.04 无法浏览互联网,OpenVPN 问题?
- c - gcc 弱属性不一致的行为
- c# - .cs 代码中两个条件的组合
- python - pytest 在启动时标记异步补丁默认事件循环