0

I am getting started with react-native development. I am using react-native-video to add a video in my application.

I wanted to seek back and forth in a video in a for-loop and hold it for a given timeout using React-Native. I am using react-native-video as the video component. The following is my code.

for (let i = 0; i < count; i++) {
        var v1 = data.ModelList[i].Value;
        var duration = data.ModelList[i].Duration;

        new Promise((resolve) => {
          setTimeout(() => resolve(this.player.seek((v1*10+15),0)), duration);
        }); 
}

Expectation: In each iteration, I want to seek the video and wait for certain milliseconds and move to the next iteration of the for-loop.

Can someone help me with this

Sanke
  • 676
  • 2
  • 13
  • 30

1 Answers1

0

Finally managed to create a recursive fucntion which will do the job.

videoSeekAnim(data, count) {
      this.player.seek(newC, 100);
      if (count < ItemCount) {
        setTimeout(function () {
          this.videoSeekAnim(data, count + 1);
        }.bind(this), 20);
      } 
    }
  }

This works. But it is not smooth engouh. Hope this might be helpful for someone.

Sanke
  • 676
  • 2
  • 13
  • 30