From ea3f1e789f870e853a9db08a03bd8f70d6598e63 Mon Sep 17 00:00:00 2001 From: apexad <1437332+apexad@users.noreply.github.com> Date: Mon, 7 Dec 2020 20:54:28 -0700 Subject: [PATCH] fix: correction to bit 11 (playing status bit) --- src/platformAccessory.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/platformAccessory.ts b/src/platformAccessory.ts index eb723ba..17ea1ac 100644 --- a/src/platformAccessory.ts +++ b/src/platformAccessory.ts @@ -55,10 +55,10 @@ export default class AirportExpress implements AccessoryPlugin { } convertMediaState(mDNS_TXT_record: Array) { - const bit11 = parseInt(((parseInt(mDNS_TXT_record.find((row: string) => row.indexOf('flags') > -1)!.replace('flags=', ''), 16).toString(2)).padStart(11, '0')).charAt(0)); - if (bit11 === 0) { + const bit11 = (parseInt(mDNS_TXT_record.find((r: string) => r.indexOf('flag') > -1)!.replace('flags=', ''), 16).toString(2)).padStart(12, '0').charAt(0); + if (bit11 === '0') { return this.hap.Characteristic.CurrentMediaState.PAUSE; - } else if (bit11 === 1) { /* bit11 correspponds to playing https://github.com/openairplay/airplay-spec/blob/master/src/status_flags.md */ + } else if (bit11 === '1') { /* bit11 correspponds to playing https://github.com/openairplay/airplay-spec/blob/master/src/status_flags.md */ return this.hap.Characteristic.CurrentMediaState.PLAY; } return this.hap.Characteristic.CurrentMediaState.STOP;