nf-audio
Custom audio player with seeking, segment playback, speed, volume and replaceable controls.
Import the components below; see the package README for standalone installation.
Basic usage
Loading example…
Basic usage
Attribute
| parameters | Description | Type | Optional value | Default value |
|---|---|---|---|---|
| src | audio recording file | string | — | '' |
| size | Size | string | mini | undefined |
| disabled | Whether to disable | boolean | — | false |
| background | Whether to display the background; false to remove the background. | boolean | — | true |
| jump-time | Specify frame skip time | number | — | 0 |
| show-jump-time | Turn off frame skipping | number(unit seconds) | — | true |
| back-second | Specify the number of seconds to rewind, 0 turns off the rewind function | number | — | 0 |
| forward-second | Specify the number of seconds to fast forward, 0 turns off the fast forward function | number | — | 0 |
| init-volumn-value | Specify the default volume, ranging from 0 to 1 | number / string | — | 0.8 |
| init-speed-value | Specify default playback speed | number / string | — | 1 |
| multiple-array | Double speed option | Array | — | ['1.0', '1.25', '1.5', '1.75', '2.0', '2.5', '3.0', '3.5', '4.0', '10.0'] |
| show-more-btn | Pass false to turn off double speed and downloading | boolean | — | true |
| speed-desc | Multiplication function description | string | — | undefined |
| download-desc | Download function description | string | — | undefined |
| speed-pre-desc | Speed option description prefix, default such as 1x, 2x | string | — | 'x ' |
| cross-time-tip | The start time cannot be greater than the total duration | string | — | undefined |
| unload-tip | Audio resources cannot be played at the moment | string | — | undefined |
| between-start | Interval playback start time, in seconds. | number | — | 0 |
| between-end | Interval playback end time, unit second; 0 means playback to the end. | number | — | 0 |
| high-precision | Turn on AudioWorklet auxiliary timing, which requires security context; falls back to RAF/timeupdate when unavailable, and does not guarantee a fixed error. | boolean | — | false |
| debuglog | Output fallback logs when a high-precision clock is unavailable. | boolean | — | false |
| download-enabled | Whether to enable downloading functions (including copying audio addresses and opening new tabs) | boolean | — | true |
| copySuccessDesc | Prompt for successful copying of audio address. | string | — | Follow language pack |
| copyAddressDesc | Copy the menu text of the audio address. | string | — | Follow language pack |
| openWindowDesc | Menu text for new tab opening. | string | — | Follow language pack |
Event
| event name | Description | callback parameters |
|---|---|---|
| download | Download callback | e:Event |
| volumeChange | Volume change | volume: number(0…100) |
| speedChange | speed change | speed: speed of change |
| jumpToTime | frame skipping | (time: time to jump to,autoPlay:Whether to play automatically Boolean Defaulttrue) |
| updateProgress | Positioning progress | offsetX: Positioning offset |
| pauseOrPlay | play/pause | paused: Whether to pause |
| forward | fast forward | time: Fast forward to time |
| back | Rewind | time: Fast rewind to time |
| error | Resource loading error | error: Event / Error |
| canPlay | Resource loaded successfully | totalTime: string(mm:ss) |
| updateTime | Native timeupdate event. | event: Event |
| native media events | Transparently transmit native events such as play, pause, ended, loadedmetadata, canplay, seeking, seeked, volumechange, ratechange, etc. | event: Event |
Slot
| Name | Description |
|---|---|
| jump | Customized frame skipping |
| play | Customized playback and pause |
| time | Customized play time |
| fastBack | Customized rewind |
| progress | Customized progress |
| fastForward | Customized fast forward |
| volume | Custom volume |
| more | Customize more |
| volume-mute | Custom mute icon. |
| volume-unmute | Custom unmute icon. |
| more-btn-list | Customize more menu content. |
| speed-btn-list | Customize double speed menu content. |
Expose
| Name | Type | Description |
|---|---|---|
| locationToTime | Function | frame skipping |
| handleBack | Function | Rewind |
| handleForward | Function | fast forward |
| handlePauseOrPlay | Function | Pause or play |
| pause | Function | pause |
| play | Function | play |
| betweenPlay | Function | interval play |
| jumpToTime(time, autoPlay = true) | void | Jump to a specified number of seconds; autoplay can be turned off. |
| changeSpeed(value) | void | Set playback speed. |
| copyAddress() | Promise<boolean> | Copy the audio address. |
| openWindow() | void | Open the audio address in a new tab. |
Instructions for use
The audio example follows the recording address of common-ui. download only dispatches download requests, and file downloads are handled by the consumer. High-precision mode requires a security context; falls back when unavailable, and does not promise millisecond accuracy.
