mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 08:36:42 +00:00
moved to single-button for pairing and streaming. This closes #26
This commit is contained in:
parent
ed138f10a2
commit
55275b8c4b
@ -27,14 +27,12 @@
|
||||
<div id="streamSettings">
|
||||
<div class="mdl-select">
|
||||
<select id="selectResolution">
|
||||
<option value="NONE">Stream Resolution</option>
|
||||
<option value="1280:720">1280x720</option>
|
||||
<option value="1920:1080">1920x1080</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mdl-select">
|
||||
<select id="selectFramerate">
|
||||
<option value="NONE">Framerate</option>
|
||||
<option value="30">30fps</option>
|
||||
<option value="60">60fps</option>
|
||||
</select>
|
||||
@ -55,8 +53,7 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="button-holder">
|
||||
<button class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored" id="pairButton">Pair</button>
|
||||
<button class="mdl-button mdl-js-button mdl-button--raised mdl-button--accent" id="showAppsButton">Retrieve App List</button>
|
||||
<button class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored" id="hostChosen">Connect</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -10,9 +10,8 @@ function attachListeners() {
|
||||
$('#selectFramerate').on('change', saveFramerate);
|
||||
$('#bitrateSlider').on('input', updateBitrateField); // input occurs every notch you slide
|
||||
$('#bitrateSlider').on('change', saveBitrate); // change occurs once the mouse lets go.
|
||||
$('#pairButton').on('click', pairPushed);
|
||||
$('#hostChosen').on('click', hostChosen);
|
||||
$('#cancelPairingDialog').on('click', pairingPopupCanceled);
|
||||
$('#showAppsButton').on('click', showAppsPushed);
|
||||
$('#selectGame').on('change', gameSelectUpdated);
|
||||
$('#startGameButton').on('click', startSelectedGame);
|
||||
$('#cancelReplaceApp').on('click', cancelReplaceApp);
|
||||
@ -80,10 +79,8 @@ function hideAllWorkflowDivs() {
|
||||
// do NOT hide the nacl module. you can't interact with it then
|
||||
}
|
||||
|
||||
// pair button was pushed. pass what the user entered into the GFEHostIPField.
|
||||
function pairPushed() {
|
||||
updateTarget();
|
||||
|
||||
// pair to the given hostname or IP
|
||||
function pairTo(targetHost) {
|
||||
if(!pairingCert) {
|
||||
snackbarLog('ERROR: cert has not been generated yet. Is NaCL initialized?');
|
||||
console.log("User wants to pair, and we still have no cert. Problem = very yes.");
|
||||
@ -91,7 +88,7 @@ function pairPushed() {
|
||||
}
|
||||
|
||||
if(!api) {
|
||||
api = new NvHTTP(target, myUniqueid);
|
||||
api = new NvHTTP(targetHost, myUniqueid);
|
||||
}
|
||||
|
||||
if(api.paired) {
|
||||
@ -99,12 +96,12 @@ function pairPushed() {
|
||||
}
|
||||
|
||||
$('#pairButton').html('Pairing...');
|
||||
snackbarLog('Attempting pair to: ' + target);
|
||||
snackbarLog('Attempting pair to: ' + targetHost);
|
||||
var randomNumber = String("0000" + (Math.random()*10000|0)).slice(-4);
|
||||
var pairingDialog = document.querySelector('#pairingDialog');
|
||||
$('#pairingDialogText').html('Please enter the number ' + randomNumber + ' on the GFE dialog on the computer. This dialog will be dismissed once complete');
|
||||
pairingDialog.showModal();
|
||||
console.log('sending pairing request to ' + target + ' with random number ' + randomNumber);
|
||||
console.log('sending pairing request to ' + targetHost + ' with random number ' + randomNumber);
|
||||
|
||||
api.pair(randomNumber).then(function (paired) {
|
||||
if (!paired) {
|
||||
@ -112,7 +109,7 @@ function pairPushed() {
|
||||
$('#pairButton').html('Pairing Failed');
|
||||
$('#pairingDialogText').html('Error: Pairing failed');
|
||||
if (api.currentGame != 0)
|
||||
snackbarLog(target + ' is already in game. Cannot pair!');
|
||||
snackbarLog(targetHost + ' is already in game. Cannot pair!');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -122,31 +119,42 @@ function pairPushed() {
|
||||
|
||||
var hostSelect = $('#selectHost')[0];
|
||||
for(var i = 0; i < hostSelect.length; i++) { // check if we already have the host.
|
||||
if (hostSelect.options[i].value == target) return;
|
||||
if (hostSelect.options[i].value == targetHost) return;
|
||||
}
|
||||
|
||||
var opt = document.createElement('option');
|
||||
opt.appendChild(document.createTextNode(target));
|
||||
opt.value = target;
|
||||
opt.appendChild(document.createTextNode(targetHost));
|
||||
opt.value = targetHost;
|
||||
$('#selectHost')[0].appendChild(opt);
|
||||
hosts.push(target);
|
||||
hosts.push(targetHost);
|
||||
saveHosts();
|
||||
|
||||
showAppsPushed();
|
||||
});
|
||||
}
|
||||
|
||||
function hostChosen() {
|
||||
updateTarget();
|
||||
|
||||
if(!api || api.address != target) {
|
||||
api = new NvHTTP(target, myUniqueid);
|
||||
}
|
||||
|
||||
api.refreshServerInfo().then(function (ret) {
|
||||
if(!api.paired) {
|
||||
pairTo(target);
|
||||
}
|
||||
showApps();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function pairingPopupCanceled() {
|
||||
document.querySelector('#pairingDialog').close();
|
||||
}
|
||||
|
||||
// someone pushed the "show apps" button.
|
||||
// if they entered something in the GFEHostIPField, use that.
|
||||
// otherwise, we assume they selected from the host history dropdown.
|
||||
function showAppsPushed() {
|
||||
updateTarget();
|
||||
|
||||
if(!api || !api.paired) {
|
||||
// show the app list
|
||||
function showApps() {
|
||||
if(!api || !api.paired) { // safety checking. shouldn't happen.
|
||||
console.log('Moved into showApps, but `api` did not initialize properly! Failing.');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -369,12 +377,10 @@ function onWindowLoad(){
|
||||
if(chrome.storage) {
|
||||
// load stored resolution prefs
|
||||
chrome.storage.sync.get('resolution', function(previousValue) {
|
||||
$('#selectResolution')[0].remove(0);
|
||||
$('#selectResolution').val(previousValue.resolution != null ? previousValue.resolution : '1280:720');
|
||||
});
|
||||
// load stored framerate prefs
|
||||
chrome.storage.sync.get('frameRate', function(previousValue) {
|
||||
$('#selectFramerate')[0].remove(0);
|
||||
$('#selectFramerate').val(previousValue.frameRate != null ? previousValue.frameRate : '30');
|
||||
});
|
||||
// load previously connected hosts
|
||||
|
Loading…
x
Reference in New Issue
Block a user