removed testing UI, added ability to resume app

This commit is contained in:
R. Aidan Campbell 2016-03-11 13:48:58 -05:00
parent 028156609b
commit 39e4f806c9
3 changed files with 10 additions and 67 deletions

View File

@ -60,11 +60,6 @@
</div> </div>
</div> </div>
<div id="testingDiv">
<button id="startButton" class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored">Start Testing Stuff</button>
<button id="stopButton" class="mdl-button mdl-js-button mdl-button--raised mdl-button--accent">Stop Testing Stuff</button>
</div>
<div id="gameSelection" class="mdl-select"> <div id="gameSelection" class="mdl-select">
<p>Select a game to run</p> <p>Select a game to run</p>
<select id="selectGame"> </select> <select id="selectGame"> </select>

View File

@ -63,22 +63,12 @@ main {
margin-top: 10px; margin-top: 10px;
margin-bottom: 10px; margin-bottom: 10px;
} }
#testingDiv {
border: 1px dashed;
padding: 10px;
}
#pairButton { #pairButton {
margin: 3px; margin: 3px;
} }
#showAppsButton { #showAppsButton {
margin: 3px; margin: 3px;
} }
#startButton {
margin: 3px;
}
#stopButton {
margin: 3px;
}
#listener { #listener {
overflow: hidden; overflow: hidden;
margin-top: 20px; margin-top: 20px;

View File

@ -6,8 +6,6 @@ var api;
// Called by the common.js module. // Called by the common.js module.
function attachListeners() { function attachListeners() {
$('#startButton').on('click', startPushed);
$('#stopButton').on('click', stopPushed);
$('#pairButton').on('click', pairPushed); $('#pairButton').on('click', pairPushed);
$('#showAppsButton').on('click', showAppsPushed); $('#showAppsButton').on('click', showAppsPushed);
$('#selectResolution').on('change', saveResolution); $('#selectResolution').on('change', saveResolution);
@ -157,46 +155,6 @@ function showAppsMode() {
$("body").css('backgroundColor', 'white'); $("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() { function startSelectedGame() {
// do NOT update the target. // do NOT update the target.
// we're just grabbing the currently selected option from #selectGame, and feeding it into NvHTTP // 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) { if(!api || !api.paired) {
api = new NvHTTP(target, myUniqueid); 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. // refresh the server info, because the user might have quit the game.
api.refreshServerInfo().then(function (ret) { api.refreshServerInfo().then(function (ret) {
if(api.currentGame != 0) { if(api.currentGame != 0 && api.currentGame != appID) {
api.getAppById(api.currentGame).then(function (currentApp) { api.getAppById(api.currentGame).then(function (currentApp) {
snackbarLog('Error: ' + target + ' is already in app: ' + currentApp.title); snackbarLog('Error: ' + target + ' is already in app: ' + currentApp.title);
}); });
console.log('ERROR! host is already in an app.'); console.log('ERROR! host is already in an app.');
return; return;
} }
var appID = $("#selectGame")[0].options[$("#selectGame")[0].selectedIndex].value;
var frameRate = $("#selectFramerate").val(); var frameRate = $("#selectFramerate").val();
var streamWidth = $('#selectResolution option:selected').val().split(':')[0]; var streamWidth = $('#selectResolution option:selected').val().split(':')[0];
var streamHeight = $('#selectResolution option:selected').val().split(':')[1]; var streamHeight = $('#selectResolution option:selected').val().split(':')[1];
@ -225,6 +183,12 @@ function startSelectedGame() {
var rikey = '00000000000000000000000000000000'; var rikey = '00000000000000000000000000000000';
var rikeyid = 0; 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, api.launchApp(appID,
streamWidth + "x" + streamHeight + "x" + frameRate, streamWidth + "x" + streamHeight + "x" + frameRate,
1, // Allow GFE to optimize game settings 1, // Allow GFE to optimize game settings
@ -264,13 +228,6 @@ function fullscreenNaclModule() {
module.style.paddingTop = ((screenHeight - module.height) / 2) + "px"; 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() { function stopGame() {
if(!api || !api.paired) { if(!api || !api.paired) {
api = new NvHTTP(target, myUniqueid); api = new NvHTTP(target, myUniqueid);
@ -278,6 +235,7 @@ function stopGame() {
api.refreshServerInfo().then(function (ret) { api.refreshServerInfo().then(function (ret) {
return api.quitApp(); return api.quitApp();
}); });
showAppsMode();
} }
function storeData(key, data, callbackFunction) { function storeData(key, data, callbackFunction) {