Skip to content

Commit 7e72442

Browse files
committed
Add initial version of settings overlay
1 parent 36ac644 commit 7e72442

File tree

1 file changed

+43
-6
lines changed

1 file changed

+43
-6
lines changed

lib/live_ex_webrtc/player.ex

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ defmodule LiveExWebRTC.Player do
6060
use Phoenix.LiveView
6161

6262
require Logger
63+
64+
import LiveExWebRTC.CoreComponents
65+
6366
alias ExWebRTC.RTPCodecParameters
6467
alias ExWebRTC.RTP.{H264, VP8}
6568
alias LiveExWebRTC.Player
@@ -207,11 +210,31 @@ defmodule LiveExWebRTC.Player do
207210
@impl true
208211
def render(assigns) do
209212
~H"""
210-
<div class="">
211-
<video id={@player.id} phx-hook="Player" class={@class} controls autoplay muted></video>
212-
<select id="lexp-video-quality">
213-
<option :for={{id, layer} <- @publisher.video_layers} value={id}>{layer}</option>
214-
</select>
213+
<div class={@class}>
214+
<div class="group inline-block relative w-full h-full">
215+
<video id={@player.id} phx-hook="Player" class="w-full h-full" controls autoplay muted>
216+
</video>
217+
218+
<div class={"z-40 absolute top-0 left-0 #{@display_settings} w-full h-full opacity-75 bg-black"}>
219+
<div class="p-4 flex flex-row">
220+
<div class="flex flex-col h-full gap-4 border-r-4 py-4 px-4 pr-8 font-bold text-white">
221+
<span class="cursor-pointer">Video Quality </span>
222+
<span class="cursor-pointer">Nerd Stats </span>
223+
<span class="cursor-pointer" phx-click="toggle-settings">Exit</span>
224+
</div>
225+
<div class="py-4 px-8 pr-4 ">
226+
<select id="lexp-video-quality" class="z-40 ">
227+
<option :for={{id, layer} <- @player.video_layers} value={id}>{layer}</option>
228+
</select>
229+
</div>
230+
</div>
231+
</div>
232+
233+
<span
234+
phx-click="toggle-settings"
235+
class="hero-cog-8-tooth text-white w-16 h-16 absolute top-[50%] left-[50%] translate-y-[-75%] translate-x-[-50%] transform duration-300 ease-in-out group-hover:visible invisible transition-opacity opacity-0 group-hover:opacity-100"
236+
/>
237+
</div>
215238
</div>
216239
"""
217240
end
@@ -229,7 +252,7 @@ defmodule LiveExWebRTC.Player do
229252
{^ref, %Player{publisher_id: ^pub_id} = player} ->
230253
player = %Player{player | layer: "h", target_layer: "h"}
231254
PubSub.subscribe(player.pubsub, "streams:info:#{player.publisher_id}")
232-
assign(socket, player: player)
255+
assign(socket, player: player, display_settings: "hidden")
233256
after
234257
5000 -> exit(:timeout)
235258
end
@@ -370,6 +393,20 @@ defmodule LiveExWebRTC.Player do
370393
end
371394
end
372395

396+
@impl true
397+
def handle_event("toggle-settings", _params, socket) do
398+
socket =
399+
case socket.assigns do
400+
%{display_settings: "hidden"} ->
401+
assign(socket, :display_settings, "flex")
402+
403+
%{display_settings: "flex"} ->
404+
assign(socket, :display_settings, "hidden")
405+
end
406+
407+
{:noreply, socket}
408+
end
409+
373410
@impl true
374411
def handle_event("offer", unsigned_params, socket) do
375412
%{player: player} = socket.assigns

0 commit comments

Comments
 (0)