Line Waveform
A waveform visualization using a continuous line. It shows playback progress and lets users seek by clicking or using arrow keys.
Basic usage
Link it to a recording element using the for attribute.
<fortyfour-recording
id="rec"
recording-id="YOUR_RECORDING_ID"
preload="metadata"
></fortyfour-recording>
<fortyfour-line-waveform for="rec"></fortyfour-line-waveform>
The waveform renders as a continuous line that follows the recording's audio data. The portion to the left of the playback position uses the progress color. The portion to the right uses the track color.
Sharp vs smooth
The sharp attribute switches from a smooth curve to straight lines between points.
<!-- Smooth curves (default) -->
<fortyfour-line-waveform for="rec"></fortyfour-line-waveform>
<!-- Sharp straight lines -->
<fortyfour-line-waveform for="rec" sharp></fortyfour-line-waveform>
Customizing the line
Control the size and shape of the waveform with attributes.
<fortyfour-line-waveform
for="rec"
line-width="3"
height="80"
></fortyfour-line-waveform>
| Attribute | Type | Default | Description |
|---|---|---|---|
line-width |
number | 2 |
Width of the line in pixels |
height |
number | 56 |
Total component height in pixels |
sharp |
boolean | false |
Use straight lines instead of curves |
Colors
Set the progress and track colors with CSS variables.
fortyfour-line-waveform {
--waveform-progress-color: #c4956a;
--waveform-track-color: #e5e7eb;
}
The progress color fills the portion that has already played. The track color fills the portion that has not played yet.
Keyboard support
When the waveform has focus, use arrow keys to seek through the recording.
| Key | Action |
|---|---|
| Left arrow | Seek backward |
| Right arrow | Seek forward |
Reference
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
for |
string | required | ID of the <fortyfour-recording> to link to |
line-width |
number | 2 |
Width of the line in pixels |
height |
number | 56 |
Total component height in pixels |
sharp |
boolean | false |
Use straight lines instead of curves |
CSS Variables
| Variable | Default | Description |
|---|---|---|
--waveform-progress-color |
#3b82f6 |
Color of played portion |
--waveform-track-color |
#e5e7eb |
Color of unplayed portion |
--waveform-focus-color |
#3b82f6 |
Focus ring color |
--waveform-focus-width |
2px |
Focus ring width |
--waveform-focus-offset |
2px |
Focus ring offset |
--waveform-focus-radius |
4px |
Focus ring border radius |