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

30 lines
569 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>
2020-04-28 21:09:54 +12:00
<img src="<%= @img_src %>">
</div>
"""
end
def mount(_params, _context, socket) do
2020-04-28 21:09:54 +12:00
socket =
if connected?(socket) do
assign(socket, img_src: "/camera/stream")
else
assign(socket, img_src: "/camera/static")
end
2020-04-28 21:09:54 +12:00
{:ok, socket}
end
end