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"} />
P粉0463871332023-09-13 14:42:21
You can use the onPlaybackStatusUpdate
attribute. This is a callback function that receives a PlaybackStatus
object as a parameter.
PlaybackStatus
object has a positionMillis
property that represents the current position of the playhead in milliseconds.
For example:
<Video { ...props } onPlaybackStatusUpdate={status => console.log(status.positionMillis)} />
For more information, see Expo AV Documentation, Expo AV Usage, positionMillis
Properties
P粉9564410542023-09-13 00:47:02
To achieve this, call this function in props.
playbackCallBack={(e) => { console.log(e.positionMillis) }
You can then use progressUpdateIntervalMillis: 1000 in the videoProps property to adjust how often (in milliseconds) the event fires.