Skip to content

Commit

Permalink
Add shorts for audio and video
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanklosko committed Aug 8, 2023
1 parent 4759cc5 commit b22a9af
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion lib/kino/shorts.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ defmodule Kino.Shorts do
def data_table(tabular, opts \\ []), do: Kino.DataTable.new(tabular, opts)

@doc """
Renders images of any given format.
Renders an image of any given format.
It is a wrapper around `Kino.Image.new/2`.
Expand All @@ -47,6 +47,36 @@ defmodule Kino.Shorts do
@spec image(binary(), Kino.Image.common_image_type() | Kino.Image.mime_type()) :: Kino.Image.t()
def image(content, type), do: Kino.Image.new(content, type)

@doc """
Renders an audio of any given format.
It is a wrapper around `Kino.Audio.new/2`.
## Examples
import Kino.Shorts
content = File.read!("/path/to/audio.wav")
audio(content, :wav)
"""
@spec audio(binary(), Kino.Audio.common_audio_type() | Kino.Audio.mime_type()) :: Kino.Audio.t()
def audio(content, type), do: Kino.Audio.new(content, type)

@doc """
Renders a video of any given format.
It is a wrapper around `Kino.Audio.new/2`.
## Examples
import Kino.Shorts
content = File.read!("/path/to/video.mp4")
video(content, :mp4)
"""
@spec video(binary(), Kino.Video.common_video_type() | Kino.Video.mime_type()) :: Kino.Video.t()
def video(content, type), do: Kino.Video.new(content, type)

@doc """
Renders a file download button.
Expand Down

0 comments on commit b22a9af

Please sign in to comment.