Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
(#692) Fix duration mismatch between audio and metadata
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
demophoon committed Feb 7, 2022
1 parent af82bcd commit f3aa9f2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/components/VAudioTrack/VAudioTrack.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
const message = computed(() => store.state.active.message)
Expand Down
5 changes: 4 additions & 1 deletion src/components/VAudioTrack/VGlobalAudioTrack.vue
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@ export default defineComponent({
/* Timekeeping */
const duration = computed(() => (props.audio?.duration ?? 0) / 1e3) // seconds
const duration = computed(
() =>
(activeAudio.obj.value?.duration ?? props.audio?.duration ?? 0) / 1e3
) // seconds
const message = computed(() => store.state.active.message)
Expand Down

0 comments on commit f3aa9f2

Please sign in to comment.