I am trying to make my home page like instagram. so like instagram, I want to play video only when scrollview reach that video and video will play automatically.
I have tried this code
<ScrollView ref={ref => this.scrollView = ref}
horizontal={false}
automaticallyAdjustContentInsets={true}
onMomentumScrollEnd={() => this.handleScrollEnd()}
contentContainerStyle={{flexGrow: 1}}
style={{height: '100%'}}
onContentSizeChange={this.handleSize}
>
<View style={style.mianContainer}>
{
this.state.publicPost.map((item, index) => {
return(
<Video
ref={ref => this.state.post_id = ref}
source={{ uri: this.state.postData.videos[0] }}
resizeMode={'cover'}
repeat={true}
muted = {true}
style={style.postImage}
onLoad={() => {
//this.state.postData.id.seek(2);
this.setState({ imageLoader: false });
}}
/>
);
})
}
</View>
</ScrollView>
I am trying with measure function to get position of video but can't idea how to match with current screen frame.
thanks!