diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 6f12c02..10b25d9 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -34,4 +34,4 @@ jobs: push: true tags: | vassio/rtsp-samsung-tv:latest - vassio/rtsp-samsung-tv:1.1.20 + vassio/rtsp-samsung-tv:1.1.21 diff --git a/CameraDevice/CameraDevice.wgt b/CameraDevice/CameraDevice.wgt index ed485a9..ecbe4a6 100644 Binary files a/CameraDevice/CameraDevice.wgt and b/CameraDevice/CameraDevice.wgt differ diff --git a/CameraDevice/index.html b/CameraDevice/index.html index 039eba0..993824a 100644 --- a/CameraDevice/index.html +++ b/CameraDevice/index.html @@ -19,31 +19,31 @@ diff --git a/CameraDevice/main.js b/CameraDevice/main.js index c2983aa..a223c8e 100644 --- a/CameraDevice/main.js +++ b/CameraDevice/main.js @@ -1,21 +1,23 @@ +'use strict'; + /* eslint no-sequences: 0 */ // --> OFF /* eslint no-unused-expressions: 0 */ // --> OFF /* eslint no-restricted-globals: 0 */ // --> OFF /* eslint no-unused-vars: 0 */ // --> OFF /* eslint func-names: 0 */ // --> OFF -const serverInfo = { +var serverInfo = { ip: localStorage.getItem('SERVER.IP') || '0.0.0.0', // <-- Server IP port: localStorage.getItem('SERVER.PORT') || '3004', - inited: localStorage.getItem('SERVER.INITED') || false, + inited: localStorage.getItem('SERVER.INITED') || false }; -let queue = []; +var queue = []; -let changeChannel = false; +var changeChannel = false; -const next = () => { - const xhr = new XMLHttpRequest(); - const url = `http://${serverInfo.ip}:${serverInfo.port}/next?width=${window.screen.width}&height=${window.screen.height}`; +var next = function next() { + var xhr = new XMLHttpRequest(); + var url = 'http://' + serverInfo.ip + ':' + serverInfo.port + '/next?width=' + window.screen.width + '&height=' + window.screen.height; xhr.withCredentials = true; xhr.open('GET', url, true); xhr.onreadystatechange = function () { @@ -33,9 +35,9 @@ const next = () => { }; xhr.send(null); }; -const prev = () => { - const xhr = new XMLHttpRequest(); - const url = `http://${serverInfo.ip}:${serverInfo.port}/prev?width=${window.screen.width}&height=${window.screen.height}`; +var prev = function prev() { + var xhr = new XMLHttpRequest(); + var url = 'http://' + serverInfo.ip + ':' + serverInfo.port + '/prev?width=' + window.screen.width + '&height=' + window.screen.height; xhr.open('GET', url, true); xhr.onreadystatechange = function () { if (xhr.readyState === xhr.DONE) { @@ -53,68 +55,72 @@ const prev = () => { xhr.send(null); }; -const getInfo = (callback, error) => { +var getInfo = function getInfo(callback, error) { if (!serverInfo.inited) { window.location.href = '/server.html'; } else { - const xhr = new XMLHttpRequest(); - const url = `http://${serverInfo.ip}:${serverInfo.port}/info?width=${window.screen.width}&height=${window.screen.height}`; - xhr.open('GET', url, true); - xhr.withCredentials = true; - xhr.onreadystatechange = function () { - if (xhr.readyState === xhr.DONE) { - if (xhr.status === 200) { - callback(JSON.parse(xhr.responseText)); - } else { - window.location.href = '/server.html'; + (function () { + var xhr = new XMLHttpRequest(); + var url = 'http://' + serverInfo.ip + ':' + serverInfo.port + '/info?width=' + window.screen.width + '&height=' + window.screen.height; + xhr.open('GET', url, true); + xhr.withCredentials = true; + xhr.onreadystatechange = function () { + if (xhr.readyState === xhr.DONE) { + if (xhr.status === 200) { + callback(JSON.parse(xhr.responseText)); + } else { + window.location.href = '/server.html'; + } } - } - }; - xhr.onerror = function (e) { - window.location.href = '/server.html'; - console.error(xhr.statusText); - }; - xhr.send(); + }; + xhr.onerror = function (e) { + window.location.href = '/server.html'; + console.error(xhr.statusText); + }; + xhr.send(); + })(); } }; -const reload = () => { +var reload = function reload() { if (serverInfo.inited) { - const xhr = new XMLHttpRequest(); - const url = `http://${serverInfo.ip}:${serverInfo.port}/reload?width=${window.screen.width}&height=${window.screen.height}`; - xhr.withCredentials = true; - xhr.open('GET', url, true); - xhr.onreadystatechange = function () { - if (xhr.readyState === xhr.DONE) { - if (xhr.status === 200) { - console.log(xhr.responseText); - location.reload(); - } else { - console.error('There was a problem with the request.'); + (function () { + var xhr = new XMLHttpRequest(); + var url = 'http://' + serverInfo.ip + ':' + serverInfo.port + '/reload?width=' + window.screen.width + '&height=' + window.screen.height; + xhr.withCredentials = true; + xhr.open('GET', url, true); + xhr.onreadystatechange = function () { + if (xhr.readyState === xhr.DONE) { + if (xhr.status === 200) { + console.log(xhr.responseText); + location.reload(); + } else { + console.error('There was a problem with the request.'); + } } - } - }; - xhr.onerror = function (e) { - console.error(xhr.statusText); - }; - xhr.send(); + }; + xhr.onerror = function (e) { + console.error(xhr.statusText); + }; + xhr.send(); + })(); } else { getInfo(); } }; function getChannel(ch) { - const value = queue.shift(); + var value = queue.shift(); if (value) { - ch.value = `${ch.value}${value}`; // eslint-disable-line no-param-reassign + ch.value = '' + ch.value + value; // eslint-disable-line no-param-reassign getChannel(ch); } return ch; } -const sel0 = (c) => { - const xhr = new XMLHttpRequest(); - const url = `http://${serverInfo.ip}:${serverInfo.port}/sel?channel=${c}&width=${window.screen.width}&height=${window.screen.height}`; +var sel0 = function sel0(c) { + var xhr = new XMLHttpRequest(); + var url = 'http://' + serverInfo.ip + ':' + serverInfo.port + '/sel?channel=' + c + '&width=' + window.screen.width + '&height=' + window.screen.height; xhr.open('GET', url, true); xhr.onreadystatechange = function () { if (xhr.readyState === xhr.DONE) { @@ -132,13 +138,13 @@ const sel0 = (c) => { xhr.send(null); }; -const sel = (c) => { +var sel = function sel(c) { queue.push(c); if (!changeChannel) { changeChannel = true; - window.setTimeout(() => { - const ch = { value: '' }; - const newch = getChannel(ch); + window.setTimeout(function () { + var ch = { value: '' }; + var newch = getChannel(ch); changeChannel = false; queue = []; sel0(newch.value); @@ -150,27 +156,26 @@ const sel = (c) => { // channelList() // Initialize function -const init = function () { +var init = function init() { console.log('init() called'); - window.tizen.tvinputdevice.registerKeyBatch([ - 'ChannelUp', - 'ChannelDown', - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - '0']); - document.addEventListener('visibilitychange', () => { + tizen.tvinputdevice.registerKey('ChannelUp'); + tizen.tvinputdevice.registerKey('ChannelDown'); + tizen.tvinputdevice.registerKey('1'); + tizen.tvinputdevice.registerKey('2'); + tizen.tvinputdevice.registerKey('3'); + tizen.tvinputdevice.registerKey('4'); + tizen.tvinputdevice.registerKey('5'); + tizen.tvinputdevice.registerKey('6'); + tizen.tvinputdevice.registerKey('7'); + tizen.tvinputdevice.registerKey('8'); + tizen.tvinputdevice.registerKey('9'); + tizen.tvinputdevice.registerKey('0'); + document.addEventListener('visibilitychange', function () { reload(); }); // add eventListener for keydown - document.addEventListener('keydown', (e) => { + document.addEventListener('keydown', function (e) { switch (e.keyCode) { case 48: sel(0); @@ -202,19 +207,24 @@ const init = function () { case 57: sel(9); break; - case 37: // LEFT arrow + case 37: + // LEFT arrow prev(); break; - case 38: // UP arrow + case 38: + // UP arrow next(); break; - case 39: // RIGHT arrow + case 39: + // RIGHT arrow next(); break; - case 40: // DOWN arrow + case 40: + // DOWN arrow prev(); break; - case 13: // OK button + case 13: + // OK button reload(); break; case 427: @@ -223,33 +233,28 @@ const init = function () { case 428: prev(); break; - case 10009: // RETURN button + case 10009: + // RETURN button tizen.application.getCurrentApplication().exit(); break; default: - console.log(`Key code : ${e.keyCode}`); + console.log('Key code : ' + e.keyCode); break; } }, true); - const voicecontrol = tizen.voicecontrol; + var voicecontrol = tizen.voicecontrol; if (voicecontrol) { - const client = voicecontrol.getVoiceControlClient(); + var client = voicecontrol.getVoiceControlClient(); if (client) { - const commands = [ - new tizen.VoiceControlCommand('ChannelUp'), - new tizen.VoiceControlCommand('ChannelDown'), - new tizen.VoiceControlCommand('Refresh'), - new tizen.VoiceControlCommand('Select'), - new tizen.VoiceControlCommand('OK'), - - ]; - for (let i = 0; i < 1000; i++) { // eslint-disable-line no-plusplus - commands.push(new tizen.VoiceControlCommand(`${i}`)); + var commands = [new tizen.VoiceControlCommand('ChannelUp'), new tizen.VoiceControlCommand('ChannelDown'), new tizen.VoiceControlCommand('Refresh'), new tizen.VoiceControlCommand('Select'), new tizen.VoiceControlCommand('OK')]; + for (var i = 0; i < 1000; i++) { + // eslint-disable-line no-plusplus + commands.push(new tizen.VoiceControlCommand('' + i)); } try { client.setCommandList(commands, 'FOREGROUND'); - const resultListenerCallback = function (event, list, result) { + var resultListenerCallback = function resultListenerCallback(event, list, result) { if (event === 'SUCCESS') { if (!isNaN(result)) { sel(result); @@ -258,7 +263,7 @@ const init = function () { reload(); } } - console.log(`Result callback - event: ${event}, result: ${result}`); + console.log('Result callback - event: ' + event + ', result: ' + result); }; client.addResultListener(resultListenerCallback); diff --git a/CameraDevice/server.html b/CameraDevice/server.html index 3ac56fc..bc2f4a5 100644 --- a/CameraDevice/server.html +++ b/CameraDevice/server.html @@ -39,7 +39,7 @@ function getInfo(ip, port, errorCallBack) { var xhr = new XMLHttpRequest(); - const url = 'http://' + ip + ':' + port + '/info?width=' + window.screen.width + '&height=' + window.screen.height + const url = 'http://' + ip + ':' + port + '/info?width=' + window.screen.width + '&height=' + window.screen.height; xhr.open("GET", url, true); xhr.onreadystatechange = function () { // ready state event, will be executed once the server send back the data if (xhr.readyState === xhr.DONE) { @@ -47,7 +47,7 @@ localStorage.setItem("SERVER.IP", ip); localStorage.setItem("SERVER.PORT", port); localStorage.setItem("SERVER.INITED", 'true'); - window.location.href = '/index.html' + window.location.href = 'index.html'; } else { console.error(xhr.responseText); errorCallBack(xhr.responseText); @@ -65,7 +65,7 @@ if (currentFocus === focusElements.length - 1) { currentFocus = 0; } else { - currentFocus = currentFocus = 1; + currentFocus = currentFocus + 1; } focusElements[currentFocus].focus(); @@ -83,15 +83,15 @@ function save() { const ip = document.getElementById("address").value; const port = document.getElementById("port").value; - getInfo(ip, port, (text) => { + getInfo(ip, port, function(text) { document.getElementById("errorMessage").innerHTML = 'Server is Unavailable. '+text; nextFocus(); }); } - window.onload = () => { - focusElements = document.getElementsByClassName("focus-ui") + window.onload = function(){ + focusElements = document.getElementsByClassName("focus-ui"); if (focusElements && focusElements[currentFocus]) { focusElements[currentFocus].focus(); } @@ -119,13 +119,13 @@ break; } }, true); - document.getElementById("address").value = localStorage.getItem("SERVER.IP") || '0.0.0.0' - document.getElementById("port").value = localStorage.getItem("SERVER.PORT") || '3004' - getInfo(document.getElementById("address").value, document.getElementById("port").value, (text)=>{ - document.getElementById("errorMessage").innerHTML = 'Server is Unavailable. '+text - }) - } + document.getElementById("address").value = localStorage.getItem("SERVER.IP") || '0.0.0.0'; + document.getElementById("port").value = localStorage.getItem("SERVER.PORT") || '3004'; + getInfo(document.getElementById("address").value, document.getElementById("port").value, + function(text){document.getElementById("errorMessage").innerHTML = 'Server is Unavailable. '+text; }); + + }; // add eventListener for keydown diff --git a/package.json b/package.json index 866b4b8..265e3aa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rtsp-samsung-tv", - "version": "1.1.20", + "version": "1.1.21", "description": "Display RTSP streams from IP Cameras on Samsung smart TV (Tizen TV)", "main": "server.js", "scripts": {