相关疑难解决方法(0)

Pause video in flatlist when out of view

I have a flatlist showing videos. I want that when a video goes out of the view it should be paused. I am maintaining the pause state in each of the Posts component.

class Posts extends React.PureComponent {

constructor() {
 super()
 this.state = {
   pause: true,
 }

 return(){
  <Video
    pause={this.state.pause}
    //other props
  />
 }

}
Run Code Online (Sandbox Code Playgroud)

I am using react-native-video.

我已经尝试使用onViewableItemsChangedof的道具,Flatlist但是它不会改变状态。

我试过。但这似乎对我不起作用。

我应该如何进行?

react-native react-native-flatlist react-native-video

6
推荐指数
2
解决办法
1308
查看次数