Live preview

Interactive example

Loading example…

Usage

Import the component and its manager, then make it your own.

ComponentAudio
Managercreate_audio_manager

svelte

<script>
  // Import the shared stylesheet once in your application's root layout.
  import "sveltekit-ui/style.css"
  import { Audio, create_audio_manager } from "sveltekit-ui"

  const manager = create_audio_manager({
    src: "https://interactive-examples.mdn.mozilla.net/media/cc0-audio/t-rex-roar.mp3",
    title: "T. rex roar",
    type: "audio/mpeg",
    ui_type: "standard",
  })
</script>

<Audio {manager} />

API reference

Configure the manager, call its methods, and read its reactive state.

17 entries in configuration

PropertyTypeDefaultDescription
storage_pathstring nulltemplate path for retrieving audio or image sources by id
srcstring nulldirect audio source url, or retrieved via storage_id if null
storage_idstring nullid used with storage_path if src is null
typestring audio/mpegmime type for the audio source
titlestring nulltitle metadata for the audio
artiststring nullartist metadata for the audio
albumstring nullalbum metadata for the audio
image_srcstring nulldirect url for the audio artwork image
image_storage_idstring nullid used with storage_path if image_src is null
image_typestring nullmime type for the artwork image
default_skip_timenumber nullseconds to skip for nav_seek_backward / nav_seek_forward
ui_typestring standardlayout style for the audio player (standard, short, or square)
mlnumber 0margin-left in rem units
mrnumber 0margin-right in rem units
mtnumber 0margin-top in rem units
mbnumber 0margin-bottom in rem units
is_hide_imageboolean falsewhether the audio image is hidden