Im using the Expo-Video-Player package, and went to get the elapsed time of when a video is played.
<ExpoVideoPlayer
videoProps={{
resizeMode: Video.RESIZE_MODE_STRETCH,
source: {
uri: videoUrl,
},
}}
inFullscreen={false}
showControlsOnLoad={true}
videoBackground={"#fff"}
height={200}
videoRef={video}
showFullscreenButton={false}
playIcon={() => playIcon}
replayIcon={() => replayIcon}
pauseIcon={() => pauseIcon}
sliderColor={"#CE4A52"}
/>
2
Answers
To achieve this, call this in the props.
You can then adjust how often you want the event to fire (in ms) in the videoProps prop with progressUpdateIntervalMillis: 1000.
You can use
onPlaybackStatusUpdate
props. This is the callback function that receives aPlaybackStatus
object as an argument.PlaybackStatus
object haspositionMillis
property, which is the current position of the playback head in milliseconds.For example:
To learn more, see Expo AV documentation, Expo AV usage,
positionMillis
property