mirror of
https://github.com/chuot/rdio-scanner.git
synced 2026-08-13 16:33:01 -06:00
Better handling of promise return in beep()
This commit is contained in:
parent
870109e93a
commit
fff40747d2
|
|
@ -29,6 +29,7 @@ import {
|
||||||
RdioScannerEvent,
|
RdioScannerEvent,
|
||||||
RdioScannerGroup,
|
RdioScannerGroup,
|
||||||
RdioScannerGroupStatus,
|
RdioScannerGroupStatus,
|
||||||
|
RdioScannerKeypadBeeps,
|
||||||
RdioScannerLiveFeedMap,
|
RdioScannerLiveFeedMap,
|
||||||
RdioScannerSearchOptions,
|
RdioScannerSearchOptions,
|
||||||
} from './rdio-scanner';
|
} from './rdio-scanner';
|
||||||
|
|
@ -169,24 +170,18 @@ export class AppRdioScannerService implements OnDestroy {
|
||||||
|
|
||||||
beep(style = RdioScannerBeepStyle.Activate): Promise<void> {
|
beep(style = RdioScannerBeepStyle.Activate): Promise<void> {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
if (!this.beepContext || !this.config.keypadBeeps) {
|
|
||||||
resolve();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const context = this.beepContext;
|
const context = this.beepContext;
|
||||||
|
|
||||||
const gn = context.createGain();
|
const seq = this.config.keypadBeeps && this.config.keypadBeeps[style];
|
||||||
|
|
||||||
const seq = this.config?.keypadBeeps[style];
|
if (!context || !seq) {
|
||||||
|
|
||||||
if (!Array.isArray(seq) || !seq.length) {
|
|
||||||
resolve();
|
resolve();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const gn = context.createGain();
|
||||||
|
|
||||||
gn.gain.value = .1;
|
gn.gain.value = .1;
|
||||||
|
|
||||||
gn.connect(context.destination);
|
gn.connect(context.destination);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue