search

Home  >  Q&A  >  body text

How to get the elapsed time of expo video

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粉738676186P粉738676186428 days ago686

reply all(2)I'll reply

  • P粉046387133

    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.

    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

    reply
    0
  • P粉956441054

    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.

    reply
    0
  • Cancelreply