Display video duration on preview area after audio recording is completed

In the audio preview section, the player doesn’t display the recorded audio duration, which can confuse users. Additionally, the video duration keeps updating as soon as the audio starts playing.

Below is a sample JS snippet that can help resolve the duration calculation issue.

const audio = new Audio();
audio.src = URL.createObjectURL(recordedBlob);

audio.addEventListener("loadedmetadata", () => {
  if (audio.duration === Infinity) {
    // Jump to a large time to trigger correct duration
    audio.currentTime = 1e101;
    audio.ontimeupdate = () => {
      audio.ontimeupdate = null;
      console.log("Correct duration:", audio.duration);
      audio.currentTime = 0; // reset
    };
  } else {
    console.log("Duration:", audio.duration);
  }
});

Hi, can you file an issue on GitHub? It seems like a bug.

Thanks Merlijn

I created a Github issue: Display video duration on preview area after audio recording is completed · Issue #5983 · transloadit/uppy · GitHub