简体   繁体   中英

How to autoplay expo-av video on focus in flatlist

The app I'm making consist pictures and videos sharing, and my goal is to autoplay the video once it is focused, also pauses it after it is out of the view inside the FlatList.

Here is a demo of what it looks like now: 在此处输入图像描述

I have 2 questions with it:

  1. How can I achieve my goal? Please help!

  2. If the video autoplays when it becomes fully visible to the user, but the problem is, as seen in my demo, 2 videos are both in the view and fully visible, so which one should I play then?

I had your question in my mind since you posted it, the way you can implement it is with the help of the following library: https://github.com/changey/react-native-component-inview which you can set the autoplay/ is playing according to what's in view

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM