How to display the duration of the song in a loop

I have a code that I want to display the duration of each song before playback.
This code works but displays the duration code after play.
my code

<?php $i=0; while ( have_rows( 'add_album_tracks' ) ) : the_row(); 

    if(get_sub_field( 'Pre-Release' ) == 1){  ?>
     echo ('null');
    <?php } else { ?>
<div class="song amplitude-song-container amplitude-play-pause" data-amplitude-song-index="<?php echo($i); ?>">
            <div class="song-now-playing-icon-container">
              <div class="play-button-container"></div>
              <div class="now-playing"><i class="fas fa-play-circle"></i></div>
            <div class="song-meta-data">
              <span class="song-title"><?php echo get_sub_field( 'name_of_track_separate' ) ?></span>
              <span class="song-artist"></span>
            <span class="song-download">
            <i class="fas fa-download"></i>
            <span class="song-duration">
              <span class="duration">
              <span class="amplitude-duration-time" amplitude-main-time-remaining="true" data-amplitude-song-index="<?php echo($i); ?>"></span>
    <?php $i++; }  endwhile; ?>

Thanks for your patience! @danpastori would love to help, but unfortunately he is out for dealing with the passing of an immediate family member.

He’s with his family now but it may be some time before he is able to get back. Thanks for your understanding!

Hi @rayshman ,

With the duration, it will show after play because the data isn’t loaded for the song until after the song has been played. If you know the duration you can add it as a meta data field, and set it as a piece of meta data. I’m looking into solutions on how to load just the meta data efficiently for audio elements in the songs array without loading all of the songs and destroying bandwidth.