25 lines
537 B
Elixir
25 lines
537 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="<%= @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
|