View Source Kino.Audio (Kino v0.14.1)

A kino for rendering a binary audio.

Examples

content = File.read!("/path/to/audio.wav")
Kino.Audio.new(content, :wav)

content = File.read!("/path/to/audio.wav")
Kino.Audio.new(content, :wav, autoplay: true, loop: true)

Summary

Functions

Creates a new kino displaying the given binary audio.

Makes a given kino stop playing the audio.

Makes a given kino play the audio.

Types

@type common_audio_type() :: :wav | :mp3 | :mpeg | :ogg
@type mime_type() :: binary()
@type t() :: Kino.JS.Live.t()

Functions

Link to this function

new(content, type, opts \\ [])

View Source
@spec new(binary(), common_audio_type() | mime_type(), keyword()) :: t()

Creates a new kino displaying the given binary audio.

The given type can be either :wav, :mp3/:mpeg, :ogg or a string with audio MIME type.

Options

  • :autoplay - whether the audio should start playing as soon as it is rendered. Defaults to false

  • :loop - whether the audio should loop. Defaults to false

  • :muted - whether the audio should be muted. Defaults to false

@spec pause(t()) :: :ok

Makes a given kino stop playing the audio.

@spec play(t()) :: :ok

Makes a given kino play the audio.

Play has no effect if the audio is already playing.