The files of the video element and of the audio element
The document holds a copy of each slide for the present view and one for
each page of the handout view. A file in each copy would make the document
many times larger. Therefore an element holds only its number in the deck,
and the renderer writes each file one time, as a data URI, into a JSON
element, such as expresso-videos. The presenter gives an element its
source when it plays. assets/src/media.ts gives the rules of the script.
An element module with the field src and the field index uses these
functions with its own struct and its own media types, such as
%{".webm" => "video/webm"}.
Summary
Functions
Return the extension of a path in lower case, such as ".webm"
Write a list of data URIs as JSON, or return nil for an empty list
Give each element of a module in a deck its number
Return one element of a module for each number in a deck, in the order of the numbers
Make sure that a value is the path of a local file with an extension of the types
Return the data URI of each file of the elements of a module in a deck, in the order of their numbers
Functions
Return the extension of a path in lower case, such as ".webm"
iex> Expresso.Media.extension("clips/Demo.WEBM")
".webm"
Write a list of data URIs as JSON, or return nil for an empty list
The renderer writes the value into a script element with
Expresso.Json.for_script/1. A deck with no file of a kind gets nil, and
the document then holds no element.
@spec number(Expresso.Deck.t(), module(), (struct() -> term())) :: Expresso.Deck.t()
Give each element of a module in a deck its number
Each key gets a number in document order, from 0, and two elements with the
same key get the same number. The default key is the file, so sources/4
writes each file one time. Expresso.Element.Embed gives each embed a key
of its own with make_ref/0, so each embed gets its own number.
@spec numbered(Expresso.Deck.t(), module()) :: [struct()]
Return one element of a module for each number in a deck, in the order of the numbers
number/3 gives the numbers first.
@spec source(term(), %{required(String.t()) => String.t()}, String.t()) :: {:ok, String.t()} | {:error, String.t()}
Make sure that a value is the path of a local file with an extension of the types
This function is the base of the custom type of the first argument of a
media element. It does not read the file, so a missing file gives an error
at render time, as for an image. A value with : is an address, and the
element does not take it.
@spec sources( Expresso.Deck.t(), module(), %{required(String.t()) => String.t()}, String.t() ) :: [ String.t() ]
Return the data URI of each file of the elements of a module in a deck, in the order of their numbers
The function reads each file through Expresso.DeckFile, so the watch mode
renders the deck again after a change to the file. It raises for a file
that it cannot read, with the noun of the element in the message, such as
"video".