-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
241 lines (224 loc) · 8.77 KB
/
index.html
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<html>
<head>
<script src="/socket.io/socket.io.js"></script>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-Fy6S3B9q64WdZWQUiU+q4/2Lc9npb8tCaSX9FK7E8HnRr0Jz8D6OP9dO5Vg3Q9ct" crossorigin="anonymous"></script>
<style>
body{
position: relative;
touch-action: manipulation;
background-color: #000;
}
button, a{
display: flex !important;
justify-content: center;
align-items: center;
touch-action: manipulation;
border-radius: 0 !important;
}
.mute-volume-btn{
border-radius: 0.5rem !important;
padding: 20px 20px;
}
.height-10vh{
height: 10vh;
}
.height-20vh{
height: 20vh;
}
.row{
margin: auto 0 !important;
}
.all-center{
display: flex;
justify-content: center;
align-items: center;
}
#sub{
display: flex;
flex-direction: row;
clear: both;
max-width: 100vw;
height: 80vh;
scroll-snap-align: end;
overflow-y: auto;
position: relative;
}
#sub > div{
display: flex;
justify-content: center;
text-align: center;
align-items: center;
height: 100%;
width: 100%;
color: hsl(0, 0%, 100%);
font-weight: bold;
font-size: 2rem;
margin: auto;
}
#sub > a:last-child {
scroll-snap-align: end;
}
.icon-size{
display: flex;
justify-content: center;
align-items: center;
width: 25px;
height: 25px;
}
.icon-size>svg{
text-rendering: optimizeLegibility;
fill: white;
}
.dropdown-item:hover, .dropdown-item:active{
background-color: #000;
}
</style>
<script>
var socket = io()
//if(localStorage.getItem("roomID"))
//socket.emit("join room", localStorage.getItem("roomID"))
socket.on("video message",(a)=>{
var messageBody = document.getElementById('sub');
//console.log(subText.replace(/[^\w\s\']|_/g, "").replace(/\s+/g, " ").trim().split(/ |\b\s+/g));
var punctRE = /[\u2000-\u206F\u2E00-\u2E7F\\!"#$%&()*+,\-.\/:;<=>?@\[\]^_`{|}~]/g;
var spaceRE = /\s+/g;
subtitle = JSON.parse(a).replace(/\n/, ' <br>').trim().split(/ |\b\s+/g);
var text = ""
console.log(subtitle);
subtitle.forEach(element => {
text += element + " "
})
var elementA = document.createElement('div');
elementA.innerHTML = text;
messageBody.appendChild(elementA);
messageBody.scrollTop = messageBody.scrollHeight;
})
function send(e) {
var msg = e.getAttribute("data-msg");
switch (msg) {
case "play":
e.setAttribute("data-msg", "pause");// getAttribute("data-msg")
e.querySelector("i").classList.remove("fa-play");
e.classList.remove("btn-dark");
e.querySelector("i").classList.add("fa-pause");
e.classList.add("btn-light");
break;
case "pause":
e.setAttribute("data-msg", "play");
e.classList.remove("btn-light");
e.querySelector("i").classList.remove("fa-pause");
e.classList.add("btn-dark");
e.querySelector("i").classList.add("fa-play");
break;
case "subtitle-on":
e.querySelector("svg").setAttribute("fill-opacity", "0.3");
e.setAttribute("data-msg", "subtitle-off")
break;
case "subtitle-off":
e.querySelector("svg").setAttribute("fill-opacity", "1");
e.setAttribute("data-msg", "subtitle-on")
break;
case "controls-on":
e.querySelector("img").style.opacity = "0.3";
e.setAttribute("data-msg", "controls-off")
break;
case "controls-off":
e.querySelector("img").style.opacity = "1";
e.setAttribute("data-msg", "controls-on")
break;
}
socket.emit("video message", msg);
}
function sendVolume(value) {
socket.emit("video message", {type:"audioVolume", volume: value});
}
function muteOrNot(e) {
var data = e.getAttribute("data-msg");
if(data == "audio-on"){
socket.emit("video message", {type:"audioVolume", volume: 0});
e.classList.remove("btn-light");
e.classList.add("btn-danger");
e.querySelector("i").classList.remove("fa-volume-up");
e.querySelector("i").classList.add("fa-volume-off");
e.setAttribute("data-msg", "audio-off");
}
else{
socket.emit("video message", {type:"audioVolume", volume: document.getElementById("volume").value});
e.classList.add("btn-light");
e.classList.remove("btn-danger");
e.querySelector("i").classList.add("fa-volume-up");
e.querySelector("i").classList.remove("fa-volume-off");
e.setAttribute("data-msg", "audio-on");
}
}
</script>
</head>
<body>
<button id="controls" class="btn btn-link height-10vh" data-msg="controls-on" onclick="send(this)" style="position: absolute; left: 0; top: 10px; z-index: 999;">
<img src="/images/video-player.png" height="40" style="opacity: 1;">
</button>
<a id="qrCode" href="/qr" class="btn btn-light height-10vh" data-msg="controls-on" onclick="send(this)" style="position: absolute;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
width: 100px;
top: 10px; z-index: 999;">
<img src="/images/qrCodeIcon.png" height="40" style="opacity: 1;">
</a>
<button id="subtitle" class="btn btn-link height-10vh" data-msg="subtitle-on" onclick="send(this)" style="position: absolute; right: 0; top: 10px; z-index: 999;">
<svg id="sub-icon" height="100%" version="1.1" viewBox="0 0 36 36" fill-opacity="1"><use class="ytp-svg-shadow" xlink:href="#ytp-id-17"></use><path d="M11,11 C9.9,11 9,11.9 9,13 L9,23 C9,24.1 9.9,25 11,25 L25,25 C26.1,25 27,24.1 27,23 L27,13 C27,11.9 26.1,11 25,11 L11,11 Z M11,17 L14,17 L14,19 L11,19 L11,17 L11,17 Z M20,23 L11,23 L11,21 L20,21 L20,23 L20,23 Z M25,23 L22,23 L22,21 L25,21 L25,23 L25,23 Z M25,19 L16,19 L16,17 L25,17 L25,19 L25,19 Z" fill="#fff" id="ytp-id-17"></path></svg>
</button>
<div id="sub" class="row"></div>
<div class="row">
<button id="backward" class="col-3 btn btn-light height-20vh" data-msg="backward" onclick="send(this)">
<i class="fas fa-backward"></i>
</button>
<button id="playpause" class="col-6 btn btn-dark height-20vh" data-msg="play" onclick="send(this)">
<i class="fas fa-play"></i>
</button>
<style>
.slider {
appearance: none;
width: 100%;
height: 25px;
outline: none;
opacity: 0.7;
-webkit-transition: .2s;
transition: opacity .2s;
}
.slider:hover {
opacity: 1;
}
.slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 25px;
height: 25px;
background: #04AA6D;
cursor: pointer;
}
.slider::-moz-range-thumb {
width: 25px;
height: 25px;
background: #04AA6D;
cursor: pointer;
}
</style>
<!--
<div class="slidecontainer">
<input type="range" orient="vertical" min="1" max="100" value="50" class="slider" id="myRange">
</div>
-->
<button id="forward" class="col-3 btn btn-light height-20vh" data-msg="forward" onclick="send(this)">
<i class="fas fa-forward"></i>
</button>
</div>
</div>
</body>
</html>