【问题标题】:Use first frame of video as thumbnail使用视频的第一帧作为缩略图
【发布时间】:2021-08-31 06:43:48
【问题描述】:

我正在使用react-native-video

它有一个名为poster 的道具,它工作正常。但我的要求是从视频(视频的第一帧)中获取该缩略图。如果我不使用 poster(接受 url),那么它会显示空白屏幕。

知道如何将视频的第一帧用作缩略图吗?

谢谢!!!

【问题讨论】:

    标签: react-native react-native-android react-native-ios react-native-video


    【解决方案1】:

    可以使用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 道具的更多详细信息:here

    【讨论】:

      猜你喜欢
      • 2011-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-03
      • 2012-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多