defmodule LivebookWeb.Output.AudioInputComponent do use LivebookWeb, :live_component @impl true def mount(socket) do {:ok, assign(socket, endianness: System.endianness(), value: nil)} end @impl true def update(assigns, socket) do {value, assigns} = Map.pop!(assigns, :value) socket = assign(socket, assigns) socket = if value == socket.assigns.value do socket else audio_info = if value do %{ data: Base.encode64(value.data), num_channels: value.num_channels, sampling_rate: value.sampling_rate } end push_event(socket, "audio_input_change:#{socket.assigns.id}", %{audio_info: audio_info}) end {:ok, assign(socket, value: value)} end @impl true def render(assigns) do ~H"""