feat: preloading in audio tag#1075
Conversation
closetcaiman
left a comment
There was a problem hiding this comment.
nice!
I'm not a fan of the current state of Audio.tsx. Maybe we can consider refactoring it for readability in the future?
closetcaiman
left a comment
There was a problem hiding this comment.
Small nitpicks. JD overall!
| template <typename T> | ||
| concept Decoder = std::is_base_of_v<decoding::IncrementalAudioDecoder, T>; | ||
|
|
||
| template <Decoder D> |
There was a problem hiding this comment.
| template <typename T> | |
| concept Decoder = std::is_base_of_v<decoding::IncrementalAudioDecoder, T>; | |
| template <Decoder D> | |
| template <typename D> | |
| requires std::is_base_of_v<decoding::IncrementalAudioDecoder, D> |
| auto duration = std::optional<double>(); | ||
| duration = | ||
| audiodecoding::probeDuration<miniaudio_decoder::MiniAudioDecoder>(data, size, sampleRate); |
There was a problem hiding this comment.
| auto duration = std::optional<double>(); | |
| duration = | |
| audiodecoding::probeDuration<miniaudio_decoder::MiniAudioDecoder>(data, size, sampleRate); | |
| auto duration = | |
| audiodecoding::probeDuration<miniaudio_decoder::MiniAudioDecoder>(data, size, sampleRate); |
| ): Promise<number | null> { | ||
| return this.fileUtils.probeDuration(data, sampleRate); | ||
| } | ||
| } |
There was a problem hiding this comment.
Is this used anywhere else? I think it can be safely removed and the fetching line can be moved to probeDuration. Also, remember to use await here.
There was a problem hiding this comment.
Ughh, the line selection was cut. The full function is:
public async probeDurationInstance(
data: ArrayBuffer,
sampleRate?: number
): Promise<number | null> {
return await this.fileUtils.probeDuration(data, sampleRate);
}| const normalizedPreload = props.preload || 'auto'; | ||
|
|
||
| return { | ||
| ...props, | ||
| autoPlay: props.autoPlay ?? false, | ||
| controls: props.controls ?? false, | ||
| loop: props.loop ?? false, | ||
| muted: props.muted ?? false, | ||
| preload: props.preload ?? 'auto', | ||
| preload: normalizedPreload, | ||
| source: props.source ?? [], |
There was a problem hiding this comment.
| const normalizedPreload = props.preload || 'auto'; | |
| return { | |
| ...props, | |
| autoPlay: props.autoPlay ?? false, | |
| controls: props.controls ?? false, | |
| loop: props.loop ?? false, | |
| muted: props.muted ?? false, | |
| preload: props.preload ?? 'auto', | |
| preload: normalizedPreload, | |
| source: props.source ?? [], | |
| return { | |
| ...props, | |
| autoPlay: props.autoPlay ?? false, | |
| controls: props.controls ?? false, | |
| loop: props.loop ?? false, | |
| muted: props.muted ?? false, | |
| preload: props.preload || 'auto', | |
| source: props.source ?? [], |
| const preloadMode: PreloadType = | ||
| preload === 'none' || preload === 'metadata' ? preload : 'auto'; |
There was a problem hiding this comment.
Is this even necessary if we use useStableAudioProps?
| std::optional<double> FFmpegDecoder::probeDuration(const void *, size_t, int) { | ||
| return std::nullopt; | ||
| } |
There was a problem hiding this comment.
This is not defined in the header. What is this for?
Closes #
Introduced changes
Checklist