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