Implement startPosition prop to set the start time of a video
See original GitHub issueFeature Request
Add a new prop for iOS and Android to be able to set the start time a video opens at. I am open to doing the PR for this, but per the contribution guide I’m opening an issue first.
Why it is needed
Sometimes users may want to have a video start at a time other than 0:00. It’s possible to manually run a .seek in the onLoad prop, but on Android in particular for bigger video files, there is noticeable lag in this starting.
Possible implementation
In my local project we used patch-package to make this work on android. In ReactExoplayerView.java in initializePlayerSource, the start time can be used if resumePosition is not present.
Logic to set the start time in getVideoTrackInfoFromManifest would likely be needed to initialize start time as well, something like final long startTime = (this.startTime > 0 ? this.startTime : this.contentStartTime) * 1000 - 100; // s -> ms with 100ms offset But I don’t understand that section quite as well.
I haven’t looked into the swift side yet and don’t have as much knowledge there, but I believe in the setter that would be created, you could set pendingSeek and pendingSeekTime if startTime is passed in, then handleReadyToPlay would automatically seek to the correct time when the player is ready.
Code sample
After setting the startTime variable, snippet from our android patch-package:
@@ -624,11 +625,14 @@ class ReactExoplayerView extends FrameLayout implements
}
}
- boolean haveResumePosition = resumeWindow != C.INDEX_UNSET;
- if (haveResumePosition) {
+ boolean useStartTime = this.startTime > 0;
+ boolean useResumePosition = resumeWindow != C.INDEX_UNSET && resumePosition > 0;
+ if (useResumePosition) {
player.seekTo(resumeWindow, resumePosition);
+ } else if (useStartTime) {
+ player.seekTo(this.startTime * 1000); // sec to ms
}
- player.prepare(mediaSource, !haveResumePosition, false);
+ player.prepare(mediaSource, !useResumePosition && !useStartTime, false);
playerNeedsSource = false;
For iOS, I haven’t done much native work but something like this may work
@objc func setStartTime(_ startTime:Float) { if startTime > 0 { _pendingSeek = true _pendingSeekTime = startTime } }
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:5 (1 by maintainers)

Top Related StackOverflow Question
Heum, you are right. I don’t think this ‘contentStartTime’ is a good feature then … I can implement it next week for android, but I need help to support ios 😕
@freeboub any update on this? i also need similar feature; ability to start a video from given position.