From 39e4f806c9b346a915b071ec27c45c19081a8fbb Mon Sep 17 00:00:00 2001 From: "R. Aidan Campbell" Date: Fri, 11 Mar 2016 13:48:58 -0500 Subject: [PATCH] removed testing UI, added ability to resume app --- index.html | 5 ---- static/css/style.css | 10 ------- static/js/index.js | 62 +++++++------------------------------------- 3 files changed, 10 insertions(+), 67 deletions(-) diff --git a/index.html b/index.html index 0d525bf..48c509d 100644 --- a/index.html +++ b/index.html @@ -60,11 +60,6 @@ -
- - -
-

Select a game to run

diff --git a/static/css/style.css b/static/css/style.css index f04ea9d..1602183 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -63,22 +63,12 @@ main { margin-top: 10px; margin-bottom: 10px; } -#testingDiv { - border: 1px dashed; - padding: 10px; -} #pairButton { margin: 3px; } #showAppsButton { margin: 3px; } -#startButton { - margin: 3px; -} -#stopButton { - margin: 3px; -} #listener { overflow: hidden; margin-top: 20px; diff --git a/static/js/index.js b/static/js/index.js index 72d5f66..3e1653a 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -6,8 +6,6 @@ var api; // Called by the common.js module. function attachListeners() { - $('#startButton').on('click', startPushed); - $('#stopButton').on('click', stopPushed); $('#pairButton').on('click', pairPushed); $('#showAppsButton').on('click', showAppsPushed); $('#selectResolution').on('change', saveResolution); @@ -157,46 +155,6 @@ function showAppsMode() { $("body").css('backgroundColor', 'white'); } -// user wants to start a stream. We need the host, game ID, and video settings(?) -function startPushed() { - updateTarget(); - - var frameRate = $("#selectFramerate").val(); - var streamWidth = $('#selectResolution option:selected').val().split(':')[0]; - var streamHeight = $('#selectResolution option:selected').val().split(':')[1]; - // we told the user it was in Mbps. We're dirty liars and use Kbps behind their back. - var bitrate = parseInt($("#bitrateSlider").val()) * 1024; - - console.log('startRequest:' + target + ":" + streamWidth + ":" + streamHeight + ":" + frameRate + ":" + bitrate); - - var rikey = '00000000000000000000000000000000'; - var rikeyid = 0; - - api = new NvHTTP(target, myUniqueid); - api.refreshServerInfo().then(function (ret) { - if (api.currentGame == 0) { - api.getAppByName("Steam").then(function (app) { - api.launchApp(app.id, - streamWidth + "x" + streamHeight + "x" + frameRate, - 1, // Allow GFE to optimize game settings - rikey, rikeyid, - 0, // Play audio locally too - 0x030002 // Surround channel mask << 16 | Surround channel count - ).then(function (ret) { - sendMessage('startRequest', [target, streamWidth, streamHeight, frameRate, bitrate.toString(), api.serverMajorVersion.toString()]); - }); - }); - } else { - api.resumeApp(rikey, rikeyid).then(function (ret) { - sendMessage('startRequest', [target, streamWidth, streamHeight, frameRate, bitrate.toString(), api.serverMajorVersion.toString()]); - }); - } - }); - - // we just finished the gameSelection section. only expose the NaCl section - playGameMode(); -} - function startSelectedGame() { // do NOT update the target. // we're just grabbing the currently selected option from #selectGame, and feeding it into NvHTTP @@ -205,17 +163,17 @@ function startSelectedGame() { if(!api || !api.paired) { api = new NvHTTP(target, myUniqueid); } + var appID = $("#selectGame")[0].options[$("#selectGame")[0].selectedIndex].value; // refresh the server info, because the user might have quit the game. api.refreshServerInfo().then(function (ret) { - if(api.currentGame != 0) { + if(api.currentGame != 0 && api.currentGame != appID) { api.getAppById(api.currentGame).then(function (currentApp) { snackbarLog('Error: ' + target + ' is already in app: ' + currentApp.title); }); console.log('ERROR! host is already in an app.'); return; } - var appID = $("#selectGame")[0].options[$("#selectGame")[0].selectedIndex].value; - + var frameRate = $("#selectFramerate").val(); var streamWidth = $('#selectResolution option:selected').val().split(':')[0]; var streamHeight = $('#selectResolution option:selected').val().split(':')[1]; @@ -225,6 +183,12 @@ function startSelectedGame() { var rikey = '00000000000000000000000000000000'; var rikeyid = 0; + + if(api.currentGame == appID) // if user wants to launch the already-running app, then we resume it. + return api.resumeApp().then(function (ret) { + sendMessage('startRequest', [target, streamWidth, streamHeight, frameRate, bitrate.toString(), api.serverMajorVersion.toString()]); + }); + api.launchApp(appID, streamWidth + "x" + streamHeight + "x" + frameRate, 1, // Allow GFE to optimize game settings @@ -264,13 +228,6 @@ function fullscreenNaclModule() { module.style.paddingTop = ((screenHeight - module.height) / 2) + "px"; } -// user pushed the stop button. we should stop. -function stopPushed() { - sendMessage('stopRequested'); - snackbarLog('stopRequested'); - stopGame(); -} - function stopGame() { if(!api || !api.paired) { api = new NvHTTP(target, myUniqueid); @@ -278,6 +235,7 @@ function stopGame() { api.refreshServerInfo().then(function (ret) { return api.quitApp(); }); + showAppsMode(); } function storeData(key, data, callbackFunction) {