How to get the elapsed time of expo video
P粉738676186
P粉738676186 2023-09-12 18:22:23
0
2
952

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粉738676186
P粉738676186

reply all(2)
P粉046387133

You can use the onPlaybackStatusUpdate attribute. This is a callback function that receives a PlaybackStatus object as a parameter.

The

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, positionMillisProperties

P粉956441054

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template