Commit 76c16f90 authored by Samuel Elliott's avatar Samuel Elliott

Send an EXIT keypress before switching the input to close the browser

parent 3bf47764
......@@ -130,7 +130,9 @@ class TVAccessory {
for (let [source_id, data] of Object.entries(config.tv_sources || {})) {
this.tv_sources.push(Object.assign(data instanceof Array ? data = {
name: data[0], input_source_type: data[1], input_device_type: data[2]
name: data[0],
input_source_type: data[1],
input_device_type: data[2],
} : data, {source_id}));
this.addInputSourceService(this.tv_sources.length - 1, data);
......@@ -447,31 +449,35 @@ class TVAccessory {
return;
}
this.log('Setting input identifier for ' + this.name + ' to ' + identifier + ' (' + await this.getInputSourceName(identifier) + ')');
const source = this.tv_sources[identifier];
const service = this.input_source_services[identifier];
if (source) {
this.followtv.setSource(source.source_id);
this.log('Setting input identifier for ' + this.name + ' to ' + identifier + ' (' +
(await this.getInputSourceName(identifier) || service.displayName) + ')');
this.last_input_switched = identifier;
} else {
if (service.config.channel_number) {
// Switch to the TV input and show this channel
await this.followtv.setChannel(service.config.channel_number);
} else if (service.config.remote_key) {
await this.remote.send(service.config.remote_key);
} else if (service.config.app_url) {
await this.followtv.setURL(service.config.app_url);
} else {
this.log('Unsupported source');
throw new Error('Unsupported source');
}
if (source || service.config.channel_number || service.config.send_exit) {
// Send an EXIT keypress to close the browser if it's open
await this.remote.send('EXIT');
await new Promise(r => setTimeout(r, 1000));
}
this.last_input_switched = identifier;
if (source) {
await this.followtv.setSource(source.source_id);
} else if (service.config.channel_number) {
// Switch to the TV input and show this channel
await this.followtv.setChannel(service.config.channel_number);
} else if (service.config.remote_key) {
// Send a keypress to the TV
await this.remote.send(service.config.remote_key);
} else if (service.config.app_url) {
await this.followtv.setURL(service.config.app_url);
} else {
this.log('Unsupported source');
throw new Error('Unsupported source');
}
this.last_input_switched = identifier;
if (service.config.picture_zoom) {
await new Promise(r => setTimeout(r, 1000));
await this.followtv.setPictureZoom(service.config.picture_zoom);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment