Commit Graph

10 Commits

Author SHA1 Message Date
Alvaro 6cfe2a09df
Consecutive playback and per-conversation playback rate 2022-09-15 14:10:46 -06:00
Evan Hahn 74fde10ff5
Prefer `import type` when importing types 2021-10-26 14:15:33 -05:00
Josh Perez 65ddf0a9e8
Import log instead of using it off of window 2021-09-17 14:27:53 -04:00
Fedor Indutny f82639dc3a
Suspend AudioContext to save resources 2021-08-02 13:31:01 -05:00
Fedor Indutny 2cd4160422
Unify audio playback under App component 2021-06-29 12:58:29 -07:00
Fedor Indutny b1d49f7b3e
Do not compute waveform for a long audio 2021-05-12 12:18:02 -07:00
Fedor Indutny 0b969f3f42
Improve MessageAudio peaks computation
There are two parts to this change:

1. The computation of peaks is moved from `MessageAudio` to the
   `GlobalAudioContext` and thus we can limit the concurrency of the
   computations (`p-queue`!) and de-duplicate the computations as well
2. While the peaks are computed the component has to display spinning
   animation instead of empty waveform and unclickable UI.
2021-04-15 14:02:24 -07:00
Evan Hahn 77c306843d
Fix error on message details screen with audio messages 2021-03-24 15:06:12 -07:00
Fedor Indutny 8c9e556a22 Don't use `useMemo()` for AudioContext/Audio/Cache
`useMemo()` doesn't guarantee that the value won't be recomputed during
re-renders. Unfortunately, every time `AudioContext` is instantiated -
there is an audible click. This click happens during the change between
conversations and is very annoying.

Move both `AudioContext` instance to the
GlobalAudioContext's top-level declarations, and `Audio`/`WaveformCache`
to `useRef()`s.
2021-03-19 16:57:35 -04:00
Fedor Indutny 12d7f24d0f New UI for audio playback and global audio player
Introduce new UI and behavior for playing audio attachments in
conversations. Previously, playback stopped unexpectedly during window
resizes and scrolling through the messages due to the row height
recomputation in `react-virtualized`.

With this commit we introduce `<GlobalAudioContext/>` instance that
wraps whole conversation and provides an `<audio/>` element that
doesn't get re-rendered (or destroyed) whenever `react-virtualized`
recomputes messages. The audio players (with a freshly designed UI) now
share this global `<audio/>` instance and manage access to it using
`audioPlayer.owner` state from the redux.

New UI computes on the fly, caches, and displays waveforms for each
audio attachment. Storybook had to be slightly modified to accomodate
testing of Android bubbles by introducing the new knob for
`authorColor`.
2021-03-19 16:57:35 -04:00