Skip to content

Commit

Permalink
fix: Attempt to sync Safari track. #1601
Browse files Browse the repository at this point in the history
  • Loading branch information
mturoci committed Aug 10, 2023
1 parent 09f29ef commit 71ed46b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ui/src/audio_annotator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export interface AudioAnnotator {
const
WAVEFORM_HEIGHT = 200,
BODY_MIN_HEGHT = 370,
TRACK_SYNC_OFFSET = 0.05,
css = stylesheet({
body: {
minHeight: BODY_MIN_HEGHT,
Expand Down Expand Up @@ -167,7 +168,7 @@ export const XAudioAnnotator = ({ model }: { model: AudioAnnotator }) => {
}
},
onAudioEnded = () => setIsPlaying(false),
onTrackChange = (value: F, _range?: [F, F]) => skipToTime(value)(),
onTrackChange = (value: F, _range?: [F, F]) => skipToTime(value - (isPlaying ? TRACK_SYNC_OFFSET : 0))(),
onVolumeChange = (v: F) => {
if (gainNodeRef.current) gainNodeRef.current.gain.value = v
setVolumeIcon(v === 0 ? 'VolumeDisabled' : (v < 0.3 ? 'Volume1' : (v < 0.75 ? 'Volume2' : 'Volume3')))
Expand Down Expand Up @@ -238,7 +239,7 @@ export const XAudioAnnotator = ({ model }: { model: AudioAnnotator }) => {
styles={{ root: { minWidth: 180 }, slideBox: { padding: 0 } }}
// HACK: React doesn't allow for skipping batch updates in 3rd party components.
// Add a small offset to sync canvas and slider tracks.
value={currentTime + (isPlaying ? 0.05 : 0)}
value={currentTime + (isPlaying ? TRACK_SYNC_OFFSET : 0)}
max={duration}
step={0.01}
onChange={onTrackChange}
Expand Down

0 comments on commit 71ed46b

Please sign in to comment.