You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用同一VideoPlayer实例渲染多expo-video的VideoView?相关技术咨询

Expo Video 在FlatList中渲染的问题与咨询

expo-av中的Video组件已被废弃,官方推荐使用expo-video组件。但在Android平台存在限制:无法同时挂载多个来自expo-video的VideoView组件并共用同一VideoPlayer实例。现咨询以下问题:

  • 在FlatList中渲染包含VideoView的VideoCard组件的推荐方案
  • 为何expo-av支持该场景而expo-video不支持
  • 下一个Expo SDK版本是否有相关修复方案

代码示例

首页代码

<FlatList
   data={videoItems}
   keyExtractor={(item) => item.id}
   renderItem={({ item }) => <VideoCard videoItem={item} />}
   ...
/>

VideoCard组件代码(示例)

import { useEvent } from 'expo';
import { useVideoPlayer, VideoView } from 'expo-video';
import { StyleSheet, View, Button } from 'react-native';
  
const VideoCard = ({ 
        videoItem: { creator, videoUrl }
}) => {
  const player = useVideoPlayer(videoUrl, player => {
    player.loop = false;
    player.play();
  });

  const { isPlaying } = useEvent(player, 'playingChange', { isPlaying: player.playing });
  ...

  return (
     <View style={styles.contentContainer}>
      <VideoView 
          style={styles.video} 
          player={player} 
          allowsFullscreen={false} 
          allowsPictureInPicture={false}
      />
      ...
    </View>
  );
}

内容的提问来源于stack exchange,提问作者Nir

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 12:54:52