29 lines
569 B
Elixir
29 lines
569 B
Elixir
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="<%= @img_src %>">
|
|
</div>
|
|
"""
|
|
end
|
|
|
|
def mount(_params, _context, socket) do
|
|
socket =
|
|
if connected?(socket) do
|
|
assign(socket, img_src: "/camera/stream")
|
|
else
|
|
assign(socket, img_src: "/camera/static")
|
|
end
|
|
|
|
{:ok, socket}
|
|
end
|
|
end
|