-
Notifications
You must be signed in to change notification settings - Fork 63
(#692) Fix duration mismatch between audio and metadata #818
(#692) Fix duration mismatch between audio and metadata #818
Conversation
@@ -285,7 +285,9 @@ export default defineComponent({ | |||
|
|||
/* Timekeeping */ | |||
|
|||
const duration = computed(() => (props.audio?.duration ?? 0) / 1e3) // seconds | |||
const duration = computed( | |||
() => (localAudio?.duration ?? props.audio?.duration ?? 0) / 1e3 // seconds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! There's also another component that will need this update: VGlobalAudioTrack
.
You can see this component on the audio search results page when your viewport is small, like on a mobile device (or just a narrow desktop browser window).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in f3aa9f2
.
Hope its okay I added this to the single commit. Figured it was the same exact fix.
When an audio file is played and the duration from the passed properties does not match the duration of the actual audio file, e.g. the duration was rounded, the progress bar drifts outside of the total width of the VWaveform dimensions. On smaller width screens or larger tracks it is less noticeable but when the audio track is small and the screen width is large that percentage adds up to 10s or more of pixels which is where the bug crops up. This commit fixes this issue by by using the audio context's duration parameter and falling back to less specific sources for duration.
a3242fd
to
f3aa9f2
Compare
Hmm.. this actually needs more investigation before being merged. I'm still seeing the bar fall off the end.. |
I think you have the right approach, but because the One potential solution I can think of is to create a What do you think @demophoon? |
@demophoon do you think you'll have an opportunity to revisit this PR? If not, we can get another contributor to look at it, totally up to you. Thank you for your work so far! |
@dhruvkb's expertise here would be useful as well, as the primary author of the original audio track components. |
@zackkrida Oh yes! It totally slipped out of my mind after the conference. I'm looking at this again this morning. @sarayourfriend That makes total sense to me since the duration that I initially used is set before the browser has even had a chance to decode the audio track to determine the real duration. |
1087aa7
to
fc35e75
Compare
Looking good! Seems to work well on the single audio results, but for the global player there's a subtle bug. First, to activate the global audio play, open a very narrow browser window on the audio search results page, something like this: When you play an audio file, the global audio player will appear floating at the bottom of the screen. Make sure to narrow the results to just Jamendo provider (for example Next, play one audio file that you know is shorter than another. Then play another audio file. Confirm that the duration was updated for the global player. Next, play the first audio again. Notice that the duration will not be updated in the global player's context. This is because the I think in the global audio track component we need to use the
In fact, I think just adding another line below that one that does this would work: audioDuration.value = audio.duration I tried that locally and it seemed to work 👍 |
Before this commit the duration would be set based on the audio context state as the page was loaded. Since the audio file is never loaded by the time we check for the duration of the audio object, it is always null thus defaulting to the metadata for audio duration always. This commit adds a `durationchange` listener while initializing the audio object and sets the duration in a new `audioDuration` property which the computed `duration` property watches.
Oh, great catch. I didn't think about the object still being around on a second play through especially with respect to the global audio component. Updated in |
fc35e75
to
9f22864
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Thanks so much for the contribution 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So nice to see this fixed. The new code for durationchange
listening and storage in a ref seems very logical!
When an audio file is played and the duration from the passed properties
does not match the duration of the actual audio file, e.g. the duration
was rounded, the progress bar drifts outside of the total width of the
VWaveform dimensions.
On smaller width screens or larger tracks it is less noticeable but when
the audio track is small and the screen width is large that percentage
adds up to 10s or more of pixels which is where the bug crops up.
This commit fixes this issue by by using the audio context's duration
parameter and falling back to less specific sources for duration.
Fixes
Fixes #692 by @sarayourfriend
Description
Testing Instructions
Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin