An element that plays a sound file in a slide
The audio entity takes the path of an MP3, an M4A, an Ogg or a WAV file
as its first argument, relative to the working directory of the command or
to the root option of the deck. The title option names the sound for a
screen reader, and the handout view and paper show it with a note symbol.
The audio element holds only data-audio, the number of the element in
the deck, and the renderer writes each file one time, as a data URI, into
the element expresso-audios. Expresso.Media gives the reasons.
The sound plays in the present view only, with the rules of a video: while
its slide shows and the element shows at the current step. A black screen,
the menu and the overview pause it, and it starts again from the start when
its slide shows again. A browser plays sound only after the first key or
click in the document, so a sound of the first slide starts at the first
key. Without controls, the present view shows nothing in the place of
the element. docs/reference/audio-element.md gives the rules.
Summary
Functions
Make the assigns of the render function from the struct
Write the sounds of a deck as JSON, or return nil for a deck with none
Give each sound of a deck its number
Make the HTML of a sound
Make sure that the source of a sound is the path of an MP3, an M4A, an Ogg or a WAV file
Return the data URI of each file of the sounds of a deck, in the order of their numbers
Types
@type t() :: %Expresso.Element.Audio{ __spark_metadata__: term(), at: term(), class: term(), controls: term(), easing: term(), effect: term(), el: term(), index: term(), loop: term(), morph: term(), on: term(), signature: term(), speed: term(), src: term(), steps: term(), title: term() }
The struct of an audio element
Functions
Make the assigns of the render function from the struct
@spec json(Expresso.Deck.t()) :: String.t() | nil
Write the sounds of a deck as JSON, or return nil for a deck with none
@spec number(Expresso.Deck.t()) :: Expresso.Deck.t()
Give each sound of a deck its number
Expresso.Renderer calls this function before the render, and the render
function writes the number into data-audio.
@spec render(map()) :: Phoenix.HTML.safe()
Make the HTML of a sound
The audio element has no source, and the presenter gives it one. An
element with no controls gets tabindex="-1", so the key Tab does not go
into it. The caption shows the title with a note symbol in the handout
view and on paper, and the style sheet hides it in the present view.
Make sure that the source of a sound is the path of an MP3, an M4A, an Ogg or a WAV file
This function is the custom type of the first argument. It does not read the file, so a missing file gives an error at render time.
iex> Expresso.Element.Audio.source("sounds/bell.mp3")
{:ok, "sounds/bell.mp3"}
iex> {:error, _message} = Expresso.Element.Audio.source("sounds/bell.flac")
@spec sources(Expresso.Deck.t()) :: [String.t()]
Return the data URI of each file of the sounds of a deck, in the order of their numbers