send progress to airplay

This commit is contained in:
vapormusic 2022-10-15 11:35:09 +07:00
parent 7662ce64f0
commit 4c3ace12de

View file

@ -89,6 +89,18 @@ export default class RAOP {
private ondeviceup(name: any, host: any, port: any, addresses: any, text: any, airplay2: any = null) {
// console.log(this.castDevices.findIndex((item: any) => {return (item.name == host.replace(".local","") && item.port == port )}))
let d = ""
let audiook = true
try{
d = text.filter((u: any) => String(u).startsWith('features='))
if(d.length == 0) d = text.filter((u: any) => String(u).startsWith('ft='))
let features_set = d.length > 0 ? d[0].substring(d[0].indexOf("=")+1).split(',') : []
let features = [... features_set.length > 0 ? parseInt(features_set[0]).toString(2).split('') : [], ... features_set.length > 1 ? parseInt(features_set[1]).toString(2).split('') : []]
if (features.length > 0){
audiook = (features[features.length - 1 - 9] == '1')
}} catch (_){}
if (audiook){
let shown_name = name;
try {
let model = text.filter((u: any) => String(u).startsWith("model="));
@ -126,7 +138,7 @@ export default class RAOP {
} else {
this._win.webContents.executeJavaScript(`console.log('deviceFound (added)','ip: ${host_name} name:${shown_name}')`).catch((err: any) => console.error(err));
console.log("deviceFound (added)", host_name, shown_name);
}
}}
}
/**
@ -229,7 +241,7 @@ export default class RAOP {
password: sepassword,
txt: txt,
airplay2: airplay2dv,
debug: true,
debug: false,
forceAlac: false,
}),
});
@ -490,4 +502,16 @@ export default class RAOP {
}
}
}
playbackTimeDidChange(attributes: any): void {
// console.log(attributes)
if (this.airtunes && this.devices.length > 0 && attributes?.currentPlaybackTime != null && attributes?.durationInMillis != null) {
for (let i in this.devices) {
this.airtunes.setProgress(this.devices[i].controller.key, Math.round(attributes.currentPlaybackTime ), Math.floor(attributes.durationInMillis/ 1000));
}
}
}
}