forked from reisxd/TizenTube
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Trying the standalone stuff (oh boy)"
This reverts commit 4d3960f.
- Loading branch information
Showing
22 changed files
with
94 additions
and
9,279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<widget xmlns:tizen="http://tizen.org/ns/widgets" xmlns="http://www.w3.org/ns/widgets" id="https://tizentube.live" | ||
version="1.0.2" viewmodes="maximized"> | ||
<access origin="*" subdomains="true" /> | ||
<tizen:application id="I80YHgsJe2.Launcher" package="I80YHgsJe2" required_version="2.3" /> | ||
<author href="https://tizentube.live">Reis Can</author> | ||
<content src="index.html" /> | ||
<feature name="http://tizen.org/feature/screen.size.normal.1080.1920" /> | ||
<tizen:privilege name="http://tizen.org/privilege/internet" /> | ||
<tizen:privilege name="http://developer.samsung.com/privilege/network.public" /> | ||
<tizen:privilege name="http://tizen.org/privilege/tv.inputdevice" /> | ||
<feature name="http://tizen.org/feature/web.service" /> | ||
<icon src="icon.png" /> | ||
<tizen:metadata key="http://samsung.com/tv/metadata/prelaunch.support" value="true" /> | ||
<tizen:metadata key="http://tizen.org/metadata/app_ui_type/base_screen_resolution" value="extensive" /> | ||
<name>Launcher</name> | ||
<tizen:privilege name="http://tizen.org/privilege/application.launch" /> | ||
<tizen:profile name="tv-samsung" /> | ||
<tizen:setting screen-orientation="landscape" context-menu="enable" background-support="enable" encryption="disable" | ||
install-location="auto" hwkey-event="enable" /> | ||
<tizen:service id="I80YHgsJe2.LauncherService"> | ||
<tizen:content src="service/dist/index.js" /> | ||
<tizen:name>TizenTubeService</tizen:name> | ||
<tizen:description>TizenTubeService</tizen:description> | ||
</tizen:service> | ||
</widget> | ||
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://github.com/reisxd/TizenTube" version="1.0.0" viewmodes="maximized"> | ||
<tizen:application id="I80YHgsJe2.Launcher" package="I80YHgsJe2" required_version="2.3"/> | ||
<content src="index.html"/> | ||
<feature name="http://tizen.org/feature/screen.size.normal.1080.1920"/> | ||
<icon src="icon.png"/> | ||
<tizen:metadata key="http://samsung.com/tv/metadata/prelaunch.support" value="true"/> | ||
<name>Launcher</name> | ||
<tizen:privilege name="http://tizen.org/privilege/application.launch"/> | ||
<tizen:privilege name="http://tizen.org/privilege/tv.inputdevice"/> | ||
<tizen:profile name="tv-samsung"/> | ||
<tizen:setting screen-orientation="landscape" context-menu="enable" background-support="disable" encryption="disable" install-location="auto" hwkey-event="enable"/> | ||
</widget> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,90 @@ | ||
function connect_to_server() { | ||
const isTizen3 = navigator.userAgent.includes('Tizen 3.0'); | ||
var wsServer; | ||
try { | ||
wsServer = new WebSocket('ws://127.0.0.1:3000'); | ||
} catch (e) { | ||
document.getElementById('text').innerText = 'Could not connect to server..'; | ||
return; | ||
} | ||
var got_ok = false; | ||
wsServer.onmessage = function (message) { | ||
const msg = JSON.parse(message.data); | ||
if (msg.ok) { //Improve here: SDB connection can still fail here if TV Developer IP isn't right | ||
//-> Catch this and ask user to change it (can also happen if an sdb conn already exists) | ||
//tizen.application.getCurrentApplication().exit(); | ||
//return; | ||
got_ok = true; | ||
//Experimental code to address the issue | ||
} | ||
if (msg.exit) { | ||
tizen.application.getCurrentApplication().exit(); | ||
} | ||
//Store IP once hitting the key "finish" | ||
document.onkeydown = e => { | ||
if (e.keyCode == 65376) { | ||
var input = document.getElementById("ip"); | ||
localStorage.setItem("ip", input.value); | ||
alert("Set IP to " + input.value); | ||
window.location.reload(); | ||
} | ||
}; | ||
|
||
wsServer.onopen = function () { | ||
wsServer.send(JSON.stringify({ | ||
e: 'launch', | ||
version: isTizen3 | ||
})); | ||
}; | ||
function prompt_for_ip(previous_IP = "192.168.1.10") { | ||
document.getElementById("inputbox").innerHTML = ` | ||
<h2 class="text2">Set Server IP which is running the node server. (Press OK to open the keyboard)</h2> | ||
<h2 class="text2">You can specify the port of the server but it is optionnal, by default it will use the port 3000. Examples : 192.168.1.10, 192.168.1.10:8080 ...</h2> | ||
<label class="label">Server IP:</label> | ||
<input type="text" class="input" placeholder="IP Address" id="ip"> | ||
`; | ||
// Focus on input | ||
const input = document.getElementById("ip"); | ||
input.blur(); | ||
input.focus(); | ||
|
||
setTimeout(function () { | ||
if (got_ok) { | ||
document.getElementById('text').innerText = "Connection with the server was successful but the ADB connection failed... You likely did not change the TV's developer IP to your server's. Or you still have an active connection to your TV with tizen device manager. Or you need to enable/disable the Tizen3 Compatibility."; | ||
} else { | ||
document.getElementById('text').innerText = 'Could not connect to server after 10 seconds.. Check if it is running and submit again its IP.'; | ||
} | ||
return; | ||
}, 10000); | ||
//Pre-fill with the previous IP or the default one | ||
input.value = previous_IP; | ||
|
||
/*input.onblur = () => { //Not sure this is needed | ||
// Set IP | ||
localStorage.setItem("ip", input.value); | ||
alert("Set IP to " + input.value); | ||
// Reload page | ||
window.location.reload(); | ||
}*/ | ||
} | ||
|
||
function start_service(){ | ||
var testWS = new WebSocket(`ws://127.0.0.1:3000`); | ||
testWS.onerror = () => { | ||
var pkg_id = tizen.application.getCurrentApplication().appInfo.packageId; | ||
var service_id = pkg_id + ".LauncherService"; | ||
tizen.application.launchAppControl(new tizen.ApplicationControl('http://tizen.org/appcontrol/operation/service'), service_id, function () { | ||
document.getElementById('text').innerText = "Service started."; | ||
connect_to_server(); | ||
}, function (e) { | ||
alert('Launch Service failed: ' + e.message); | ||
}); | ||
}; | ||
function connect_to_server() { | ||
// Check if IP was set | ||
if (localStorage.getItem("ip") == null) { | ||
document.getElementById('text').innerText = 'Waiting for the IP of the server..'; | ||
// Set IP by prompt | ||
prompt_for_ip(); | ||
return; | ||
} else { | ||
var IP = localStorage.getItem('ip'); | ||
var IP_split = IP.split(":"); | ||
var wsServer; | ||
try { | ||
if (IP_split.length > 1) { | ||
wsServer = new WebSocket('ws://' + IP_split[0] + ":" + IP_split[1]); | ||
} else { | ||
wsServer = new WebSocket('ws://' + IP_split[0] + ':3000'); | ||
} | ||
} catch (e) { | ||
document.getElementById('text').innerText = 'Could not connect to server.. Check if it is running and submit again its IP.'; | ||
prompt_for_ip(IP); | ||
return; | ||
} | ||
var got_ok = false; | ||
wsServer.onmessage = function (message) { | ||
const msg = JSON.parse(message.data); | ||
if (msg.ok) { //Improve here: SDB connection can still fail here if TV Developer IP isn't right | ||
//-> Catch this and ask user to change it (can also happen if an sdb conn already exists) | ||
//tizen.application.getCurrentApplication().exit(); | ||
//return; | ||
got_ok = true; | ||
//Experimental code to address the issue | ||
} | ||
if(msg.exit){ | ||
tizen.application.getCurrentApplication().exit(); | ||
} | ||
} | ||
|
||
wsServer.onopen = function () { | ||
wsServer.send(JSON.stringify({ | ||
e: 'launch' | ||
})); | ||
}; | ||
|
||
testWS.onopen = () => { | ||
document.getElementById('text').innerText = "Service is already running."; | ||
testWS.close(); | ||
connect_to_server(); | ||
}; | ||
setTimeout(function () { | ||
if (got_ok) { | ||
document.getElementById('text').innerText = "Connection with the server was successful but the ADB connection failed... You likely did not change the TV's developer IP to your server's. Or you still have an active connection to your TV with tizen device manager. Or you need to enable/disable the Tizen3 Compatibility."; | ||
} else{ | ||
document.getElementById('text').innerText = 'Could not connect to server after 10 seconds.. Check if it is running and submit again its IP.'; | ||
} | ||
prompt_for_ip(IP); | ||
return; | ||
}, 10000); | ||
} | ||
} | ||
|
||
document.addEventListener("DOMContentLoaded", start_service); | ||
document.addEventListener("DOMContentLoaded", connect_to_server); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.