aboutsummaryrefslogtreecommitdiff
path: root/priv/room.html.eex
blob: c3ae92ea83de957b49525b3327421ffd3e44f206 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!DOCTYPE html>
<%
import Mediasync.Constants

{video_info, websocket_path, state_url, home_button_url, show_snap_button?} = if in_discord_activity? do
  {
    %{video_info | url: "/.proxy/room/#{room_id}/video?#{query_param_discord_activity_inner()}"},
    "/.proxy/room/#{room_id}/websocket?#{query_param_discord_activity_inner()}",
    "/.proxy/room/#{room_id}/state.json?#{query_param_discord_activity_inner()}",
    "/.proxy/?#{query_param_discord_activity_inner()}",
    true
  }
else
  {video_info, "/room/#{room_id}/websocket", "/room/#{room_id}/state.json", nil, false}
end
%>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="robots" content="noindex, nofollow">
    <title>room | mediasync</title>
    <link rel="stylesheet" href="/static/main.css">
    <link rel="stylesheet" href="/static/video.js/video-js.min.css">
    <style>
        body {
            margin: 0;
        }

        div#outerContainer {
            display: flex;
            flex-direction: row;
            align-items: center;
            height: 100svh;
            width: 100svw;
        }

        div#playerContainer {
            /* Default values; JS will adjust depending on actual aspect ratio */
            height: 100svh;
            width: 100svw;
            /* We should be in the (horizontal) center by default */
            margin: 0 auto;
        }

        div#playerContainer:has(#snap-button.icon-right) {
            /* We should be on the left */
            margin-left: 0;
        }

        div#playerContainer:has(#snap-button.icon-left-right) {
            /* We should be on the right */
            margin-left: auto;
            margin-right: 0;
        }

        #state-button-active::after {
            content: attr(data-text);
            white-space: pre-wrap;
            font-family: monospace;
            text-align: left;
            text-shadow: black 1px 1px;
            position: fixed;
            left: 0;
            top: 0;
        }
    </style>
    <!-- Will be modified by JS -->
    <style id="extra-styles"></style>
</head>

<body>
    <div id="outerContainer">
        <div id="playerContainer">
            <video-js id="player">
                <source src="<%= Plug.HTML.html_escape(video_info.url) %>"
                    type="<%= Plug.HTML.html_escape(video_info.content_type) %>">
            </video-js>
        </div>
    </div>
    <script src="/static/video.js/video.min.js"></script>
    <script>
        const WEBSOCKET_URL = location.origin.replace(/^http/, "ws") + "<%= websocket_path %>";
        const HOME_BUTTON_URL = <%= if home_button_url, do: ~s("#{home_button_url}"), else: "null" %>;
        const STATE_ELEMENT_INITIAL_TEXT = "loading...";
        const STATE_URL = "<%= state_url %>";
        const SHOW_SNAP_BUTTON = <%= show_snap_button? %>;
    </script>
    <script src="/static/room/main.js"></script>
    <script src="/static/room/displayState.js"></script>
</body>

</html>