apply starting position directly (no setTimeout)

This commit is contained in:
Travis Eden 2017-12-21 20:22:40 -05:00
parent 6c4a4e593c
commit 7d29c4b91d

View file

@ -38,11 +38,6 @@ class VideoPlayer extends React.PureComponent {
position,
} = this.props;
// I'm using a Timeout because I'm not sure where this should happen
if (position > 0) {
setTimeout(() => (mediaElement.currentTime = position), 900);
}
const loadedMetadata = e => {
this.setState({ hasMetadata: true, startedPlaying: true });
this.refs.media.children[0].play();
@ -75,6 +70,7 @@ class VideoPlayer extends React.PureComponent {
document.addEventListener("keydown", this.togglePlayListener);
const mediaElement = this.refs.media.children[0];
if (mediaElement) {
mediaElement.currentTime = position;
mediaElement.addEventListener("play", () => this.props.doPlay());
mediaElement.addEventListener("pause", () => {
console.log("CURRENT TIME:", mediaElement.currentTime);