'react-native-video onLoad onProgress not working IOS

I have used react-native video for playing audio files, it is working fine on android , but on ios it is not able to fire onLoad and onProgress functions which I am using to get duration and progress. Below is my code.

<Video source={{ uri: songPlaying.url }}
          ref="audio"
          volume={this.state.muted ? 0 : 1.0}
          muted={false}
          paused={!this.state.playing}
          onLoad={this.onLoad.bind(this)}                                                   
          onProgress={this.setTime.bind(this)}
          onEnd={this.onEnd.bind(this)}
          resizeMode="cover"
          repeat={false} />    

 onLoad(params) {
    this.setState({ songDuration: params.duration });
  }

//called in onProgress to set time.

 setTime(params) {
    if (!this.state.sliding) {
      this.setState({ currentTime: params.currentTime });
    }
  }


Solution 1:[1]

i am using react-native-video-player and i was facing this onLoad issue on IOS. So as a work around i set loading to true in onLoadStart event and i set loading to false in onVideoBuffer as well as in onLoad and onVideoLoad. This is working fine on both IOS and Android for me. here is the sample code

<VideoPlayer 
      onVideoBuffer={() => setisLoading(false)}
      onLoadStart={() => setisLoading(true)}
      onVideoLoad={() => setisLoading(false)}
      onLoad={() => setisLoading(false)}
      thumbnail={{ uri: item?.thumbnailUrl }}
      controls={false}

      paused={!autoplay || pause}
      video={{
        uri: item?.videoUrl,
      }}
/>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Agha Ali Abbas