Skip to content

Commit 8bb79d1

Browse files
committed
docs(hook): update useWaveform related documents
1 parent 8bbc51a commit 8bb79d1

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

docs/en/hook/useWaveform.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ This Hook allows you to fetch waveform data of an audio file.
3030

3131
- **channel**: `1 | 2`
3232

33-
The number of audio channels in the audio file, defaults to `2`.
33+
The number of audio channels in the audio file, defaults to `2`. ·
3434

3535
- **samples**: `number`
3636

@@ -44,6 +44,10 @@ This Hook allows you to fetch waveform data of an audio file.
4444

4545
The waveform data. Returns `number[]` when `channel` is `1` and `number[][]` when `channel` is `2`.
4646

47+
- **audioDuration**: `React.MutableRefObject<number>`
48+
49+
The duration of the audio file is in seconds and needs to be obtained using `.current`
50+
4751
- **error**: `boolean`
4852

4953
Indicates whether an error occurred during waveform data generation.

docs/zh/hook/useWaveform.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ import { Github } from 'lucide-react'
4444

4545
波形数据,当入参 `channel``1` 时返回 `number[]`,为 `2` 时返回 `number[][]`
4646

47+
- **audioDuration**: `React.MutableRefObject<number>`
48+
49+
音频文件的时长单位为秒,需要使用 `.current` 获取
50+
4751
- **error**: `boolean`
4852

4953
在生成 Waveform 数据过程中是否发生错误

packages/hooks/useWaveform.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const SAMPLES = 512 * 2
2222
*
2323
* @returns {object} An object containing the waveform data and any error information:
2424
* - data: An array of numbers (for mono) or an array of arrays of numbers (for stereo), representing the simplified waveform data.
25+
* - audioDuration: A ref object containing the duration of the audio in seconds.
2526
* - error: A boolean indicating if an error has occurred during processing.
2627
* - errorMessage: A string containing the error message if an error has occurred.
2728
*

0 commit comments

Comments
 (0)