This repository has been archived on 2024-06-24. You can view files and clone it, but cannot push or open issues or pull requests.
augie/webapp/lib/augie_web/live/camera_live.ex

25 lines
537 B
Elixir
Raw Normal View History

defmodule AugieWeb.CameraLive do
use Phoenix.LiveView
@moduledoc """
A Liveview which streams images from the raspberry pi camera.
"""
def render(assigns) do
~L"""
<div class="card">
<div class="card-divider">
<h4>Camera</h4>
</div>
<img src="<%= @camera_path %>">
</div>
"""
end
def mount(_params, _context, socket) do
camera_path = if connected?(socket), do: "/camera/stream.mjpg", else: "/camera/static.jpg"
{:ok, assign(socket, camera_path: camera_path)}
end
end