Akila

Akila

  • NA
  • 216
  • 34.5k

react native video player activity indicator

Dec 2 2021 5:01 AM

HI,

I want activity indicator while video is loading.

const [opacity, setopacity] = useState(0);
  const onLoadStart = () => {
    setopacity(1);
}
const onLoad = () => {
  setopacity(0);
}
const onBuffer = ({isBuffering}) => {
    setopacity(isBuffering ? 1 : 0);
}
 <VideoPlayer
     ref={videoPlayer}
    video={{ uri: item.file_name}}  
    style={{ width: 400, height: 250 }}  
    pauseOnPress={true} 
    onBuffer={onBuffer}
                onLoadStart={onLoadStart}
                onLoad={onLoad}   
/>
 <ActivityIndicator
 animating
 size="large"
  style={[styles.activityIndicator, {opacity:opacity}]}
/>
</View>

I am using flatlist video.Its working but if one video's activity indicator is loading automatically all video activity indicator is loading