feat: manage audio centrally in the SDK #3288
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request refactors and modernizes the audio attachment components, improving state management, playback control, and code clarity. The most significant changes are the migration to a centralized audio player state store, deprecation of legacy callback props, and improved handling for both audio and voice recording attachments. These updates enhance maintainability and user experience across both Expo and native platforms.
Starting this PR, integrators can choose to have only a single player instance at a time which can be controlled using the
allowConcurrentAudioPlaybackprop of the Channel component wherefalseis the new default. This behaviour is done in parity with React SDK and as per decision.Audio Attachment Component Refactor and State Management Improvements
useAudioPlayerControlanduseStateStore, removing the need for deprecated callback props likeonLoad,onPlayPause, andonProgress. [1] [2]isPlaying,progress,duration,currentPlaybackRate) for rendering controls, progress bars, and playback speed, replacing legacy props and local state. [1] [2] [3] [4] [5]Voice Recording and Audio Attachment Handling
isVoiceRecordingAttachmenthelper, ensuring correct duration and title display, and simplifying logic for both audio and voice recording types. [1] [2]File Attachment Group Updates
onLoad,onProgress) inFileAttachmentGroup, updating documentation and usage to encourage migration to the new state management approach. Also addedmessageprop for better context handling. [1] [2] [3]Native and Expo Audio Player Integration
Progress and Wavefrom progress control performance
Improved the progress and waveform progress bar performance by 10x as previously the animations were slow and not adhereing to the pattern that could make it fast.
These changes collectively modernize the audio attachment experience, making it more robust and easier to maintain.