From 8eb6cb5b3d34b448bfb670949013db2c87662404 Mon Sep 17 00:00:00 2001
From: Sami Spets <savasp@utu.fi>
Date: Thu, 24 Oct 2019 05:17:13 +0300
Subject: [PATCH] Started to implement lbide265

---
 web-service/server/public/js/index.js | 15 ++++++++++-----
 web-service/server/src/index.js       |  4 +++-
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/web-service/server/public/js/index.js b/web-service/server/public/js/index.js
index 182fca3eb..21f75e6dd 100644
--- a/web-service/server/public/js/index.js
+++ b/web-service/server/public/js/index.js
@@ -40,12 +40,15 @@ const getAvailableStreams = async () => {
 }
 
 const videoPlayer = () => {
-    const containerDiv = document.getElementById('container');
-    window.open(`http://localhost:8080/stream?uri=${asd}`)   
+    const containerDiv = document.getElementById('container')
+    containerDiv.innerHTML = `<h1>Stream ${current_uri} is live right here!</h1><br><button onclick="renderThumbnails()">Go back</button><br>
+    <canvas id="ftlab-stream-video" width="0" height="0"></canvas>`;
+    containerDiv.innerHTML += '<br>'
+    containerDiv.innerHTML += ''
+    let decoder = new libde265.Decoder();
+    console.log(decoder)
 }
 
-let webSocket = new WebSocket('ws://localhost:8080/')
-
 
 /**
  * Creates thumbnail (image) for all available streams and adds them to div class='container'
@@ -58,6 +61,7 @@ const renderThumbnails = async () => {
     console.log(containerDiv)
     for(var i=0; i<thumbnails.length; i++){
         const encodedURI = encodeURIComponent(thumbnails[i])
+        current_uri = encodedURI
         console.log("THUMBNAIL[i]", thumbnails[i])
         try{
             const someData = await fetch(`http://localhost:8080/stream/rgb?uri=${encodedURI}`)
@@ -77,6 +81,7 @@ const renderThumbnails = async () => {
     }
 }
 
+
 // //FOR LAPTOP
 // const renderThumbnails = async () => {
 //     const containerDiv = document.getElementById('container')
@@ -118,7 +123,7 @@ const createCard = (url, viewers, uri) => {
     return `<div class='ftlab-card-component' >
                 <img src='${url}' class="thumbnail-img" alt="Hups" width="250px"></img>
                 <p>Viewers: ${viewers}</p>
-                <button onclick="current_uri=${uri}; window.location.href='/stream?uri=${uri}';">button</button>
+                <button onclick="videoPlayer()">button</button>
             </div>`
 }
 
diff --git a/web-service/server/src/index.js b/web-service/server/src/index.js
index 6f94e8fa2..476eb8141 100644
--- a/web-service/server/src/index.js
+++ b/web-service/server/src/index.js
@@ -275,9 +275,11 @@ app.get('/stream/config', async(req, res) => {
 
 app.get('/stream', (req, res) => {
 	let uri = req.query.uri;
-	uri_data[uri]
+	console.log(uri_data[uri]);
+	
 
 	console.log(uri)
+	res.end();
 })
 
 /*
-- 
GitLab