Implement options page

This commit is contained in:
hensm
2018-07-21 01:38:07 +01:00
parent 9f7bf780e5
commit c4ed13fb0b
8 changed files with 284 additions and 14 deletions

View File

@@ -1,5 +1,7 @@
"use strict";
let options;
let chrome;
let logMessage;
@@ -122,10 +124,7 @@ async function onRequestSessionSuccess (session_) {
session = session_;
let mediaUrl = new URL(srcUrl);
// TODO: Get from extension settings
const port = 9555;
const port = options.option_localMediaServerPort;
if (isLocalFile) {
await new Promise((resolve, reject) => {
@@ -284,7 +283,7 @@ function onMediaSeekError (err) {
}
window.__onGCastApiAvailable = function (loaded, errorInfo) {
window.__onGCastApiAvailable = async function (loaded, errorInfo) {
if (!loaded) {
logMessage("__onGCastApiAvailable error");
return;
@@ -295,6 +294,15 @@ window.__onGCastApiAvailable = function (loaded, errorInfo) {
logMessage("__onGCastApiAvailable success");
options = (await browser.storage.sync.get("options")).options;
if (isLocalFile && !options.option_localMediaEnabled) {
logMessage("Local media casting not enabled");
return;
}
const sessionRequest = new chrome.cast.SessionRequest(
chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID);