Media

Audio player

Plays a recording with a timeline you can drag or step through, skips of 15 seconds, speed and volume. Its title and controls also appear on the lock screen and respond to headphone buttons.

Installation

npx sinaui add audio-player

Examples

Basic

Taxim Hicaz, played by Ahmed Djewdet around 1928. Public domain, via Wikimedia Commons.

Taxim Hicaz Ahmed Djewdet, c. 1928
<script lang="ts">
	import AudioPlayer from '#lib/ui/AudioPlayer.svelte';
</script>

<!-- Taxim Hicaz, played by Ahmed Djewdet, c. 1928. Public domain, via Wikimedia Commons. -->
<AudioPlayer
	src="https://upload.wikimedia.org/wikipedia/commons/transcoded/0/0c/Taxim_Hicaz_%28c._1928%29.ogg/Taxim_Hicaz_%28c._1928%29.ogg.mp3"
	title="Taxim Hicaz"
	artist="Ahmed Djewdet, c. 1928"
/>

With a visualizer

Bars that move with the music. The file's host must allow cross-origin requests; Wikimedia Commons does.

Taxim Hicaz Ahmed Djewdet, c. 1928
<script lang="ts">
	import AudioPlayer from '#lib/ui/AudioPlayer.svelte';
</script>

<!-- Taxim Hicaz, played by Ahmed Djewdet, c. 1928. Public domain, via Wikimedia Commons. -->
<AudioPlayer
	src="https://upload.wikimedia.org/wikipedia/commons/transcoded/0/0c/Taxim_Hicaz_%28c._1928%29.ogg/Taxim_Hicaz_%28c._1928%29.ogg.mp3"
	title="Taxim Hicaz"
	artist="Ahmed Djewdet, c. 1928"
	visualizer
/>

Props

PropTypeDefault
srcstring (required)
titlestring (required)
artiststring
artworkstring: image URL
visualizerboolean | 'bars' | 'wave'false
elementHTMLAudioElement, bindable
localestring'en'

Keyboard

On the timeline:

KeyDoes
→ / ↑Forward 5 seconds
← / ↓Back 5 seconds
PageUp / PageDownForward / back 30 seconds
Home / EndStart / end

Accessibility

  • The timeline is a native slider; screen readers hear “1 minute, 23 seconds of 3 minutes, 5 seconds”.
  • Every button is named: play or pause, back and forward 15 seconds, speed, mute.
  • Right-to-left: the timeline fills from the right and the arrow keys follow it.
  • If the file can’t load, a plain message and a Try again button replace the timeline.
  • With reduced motion, play and pause swap with a fade only.
Introduction
Theming
Changelog
Button
Action button
Confirm button
Copy button
Hold to confirm
Split button
Calendar
Checkbox
Color picker
Combobox
Date picker
Date range picker
File drop
Form
Input
Mention input
Multi select
Number field
OTP input
Password input
Phone input
Radio cards
Radio group
Rich text editor
Search field
Segmented control
Select
Signature pad
Slider
Switch
Tag input
Upload
Wheel picker
Textarea
Time field
Toggle group
Toolbar
Alert dialog
Command palette
Context menu
Dialog
Drawer
Dropdown
Hover card
Popover
Tooltip
Announcement bar
Alert
Empty state
Meter
Progress
Rolling number
Skeleton
Spinner
Toast
Avatar
Avatar group
Badge
Card
Carousel
Chart
Chat
Code block
Data table
Folder
Kbd
Mind map
Resizable panels
Scroll area
Separator
Sortable
Table
Tag group
Virtual list
Audio player
Image
Image compare
Video
Visualizer
Breadcrumb
File tree
Menubar
Navigation menu
Pagination
Sidebar layout
Stepper
Tabs
Alarm clock
Clock
Dynamic island
Fluid orb
Hourglass
Stopwatch
Timer
AI chat
AI media
Auth
Board
Booking
Dashboard
File explorer
Messaging
Notifications
Settings
Team
Overview
Pricing
Agent chat
Calendar
Voice agent
Mail inbox
CMS
Blog
Marketing site
E-commerce
AI agents
SaaS landing page
SaaS app
Accordion
Dark theme
Light theme