skip to Main Content

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


  1. Chosen as BEST ANSWER

    To achieve this, call this in the props.

    playbackCallBack={(e) => {
        console.log(e.positionMillis)
    }
    

    You can then adjust how often you want the event to fire (in ms) in the videoProps prop with progressUpdateIntervalMillis: 1000.


  2. You can use onPlaybackStatusUpdate props. This is the callback function that receives a PlaybackStatus object as an argument.

    PlaybackStatus object has positionMillis property, which is the current position of the playback head in milliseconds.

    For example:

    <Video
      { ...props }
      onPlaybackStatusUpdate={status => console.log(status.positionMillis)}
    />
    

    To learn more, see Expo AV documentation, Expo AV usage, positionMillis property

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search