I'm using the Expo-Video-Player package and want to get the elapsed time while the video is playing.
<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"} />
You can use the
TheonPlaybackStatusUpdate
attribute. This is a callback function that receives aPlaybackStatus
object as a parameter.PlaybackStatus
object has apositionMillis
property that represents the current position of the playhead in milliseconds.For example:
For more information, see Expo AV Documentation, Expo AV Usage,
positionMillis
PropertiesTo achieve this, call this function in props.
You can then use progressUpdateIntervalMillis: 1000 in the videoProps property to adjust how often (in milliseconds) the event fires.