@@ -14,6 +14,28 @@ std::mutex httpServerMutex;
14
14
15
15
std::string lastInsertChannel = " " ;
16
16
17
+ int VolumeProgressRunning = false ;
18
+ int VolumeWaitCount;
19
+
20
+ void hideVolumebar () {
21
+ // int waitTime = 100;
22
+ int waitTime = 60 ;
23
+ VolumeWaitCount = 0 ;
24
+ VolumeProgressRunning = true ;
25
+
26
+ while (VolumeWaitCount < 50 ) {
27
+ VolumeWaitCount++;
28
+ std::this_thread::sleep_for (std::chrono::milliseconds (waitTime));
29
+ }
30
+
31
+ auto frame = currentBrowser->GetMainFrame ();
32
+ if (frame != nullptr ) {
33
+ frame->ExecuteJavaScript (" document.getElementById('_volumecontainer').style.visibility= \" hidden\" ;" , frame->GetURL (), 0 );
34
+ }
35
+
36
+ VolumeProgressRunning = false ;
37
+ }
38
+
17
39
void startHttpServer (std::string browserIp, int browserPort, std::string vdrIp, int vdrPort, std::string transcoderIp, int transcoderPort) {
18
40
int _browserPort = browserPort;
19
41
std::string _browserIp = browserIp;
@@ -264,7 +286,21 @@ void startHttpServer(std::string browserIp, int browserPort, std::string vdrIp,
264
286
if (cv.empty () || mv.empty ()) {
265
287
res.status = 404 ;
266
288
} else {
267
- // TODO: Implement some HTML Widget which shows the current volume
289
+ auto frame = currentBrowser->GetMainFrame ();
290
+
291
+ if (frame != nullptr ) { // Why is it possible, that MainFrame is null?
292
+ frame->ExecuteJavaScript (" document.getElementById('_volumecontainer').style.visibility= \" visible\" ;" , frame->GetURL (), 0 );
293
+ frame->ExecuteJavaScript (" document.getElementById('_volume').value = \" " + cv + " \" ;" , frame->GetURL (), 0 );
294
+ frame->ExecuteJavaScript (" document.getElementById('_volume').max = \" " + mv + " \" ;" , frame->GetURL (), 0 );
295
+
296
+ if (VolumeProgressRunning) {
297
+ VolumeWaitCount = 0 ;
298
+ } else {
299
+ std::thread hideThread (hideVolumebar);
300
+ hideThread.detach ();
301
+ }
302
+ }
303
+
268
304
res.set_content (" ok" , " text/plain" );
269
305
}
270
306
});
0 commit comments