Audio ComponentType-safe audio element component.
Navigation

Audio Component

Type-safe audio element component.

Import

import codes.yousef.summon.components.media.Audio

Overview

The Audio component provides a type-safe audio element for playing audio content.

Function Signature

@Composable
fun Audio(
    src: String,
    autoplay: Boolean = false,
    muted: Boolean = false,
    loop: Boolean = false,
    controls: Boolean = true,
    preload: String = "metadata",
    ariaLabel: String? = null,
    modifier: Modifier = Modifier()
)

Parameters

ParameterTypeDefaultDescription
srcStringRequiredURL to the audio file
autoplayBooleanfalseWhether to start playing automatically
mutedBooleanfalseWhether the audio is muted
loopBooleanfalseWhether to loop the audio
controlsBooleantrueWhether to show playback controls
preloadString"metadata"Preload strategy: "none", "metadata", or "auto"
ariaLabelString?nullAccessibility label for the audio
modifierModifierModifier()Styling modifier for the audio element

Examples

Basic Usage

Audio(
    src = "https://example.com/audio.mp3",
    controls = true
)

Background Music (Looped)

Audio(
    src = "background.mp3",
    autoplay = true,
    loop = true,
    controls = false
)

With Accessibility Label

Audio(
    src = "podcast-episode.mp3",
    controls = true,
    ariaLabel = "Podcast Episode 42: Introduction to Kotlin"
)

Accessibility

  • Use ariaLabel to provide descriptive text for screen readers
  • Always include controls = true to allow users to control playback
  • Consider providing transcripts for audio content

See Also

Architected in Kotlin. Rendered with Materia. Powered by Aether.
© 2026 Yousef.