Skip to content

Commit e0d2df0

Browse files
committed
loop every 7 seconds
1 parent 4066bbf commit e0d2df0

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/vs/platform/audioCues/browser/audioCueService.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface IAudioCueService {
2626
onEnabledChanged(cue: AudioCue): Event<void>;
2727

2828
playSound(cue: Sound, allowManyInParallel?: boolean): Promise<void>;
29-
playAudioCueLoop(cue: AudioCue): IDisposable;
29+
playAudioCueLoop(cue: AudioCue, milliseconds: number): IDisposable;
3030
playRandomAudioCue(groupId: AudioCueGroupId, allowManyInParallel?: boolean): void;
3131
}
3232

@@ -75,10 +75,11 @@ export class AudioCueService extends Disposable implements IAudioCueService {
7575
private readonly playingSounds = new Set<Sound>();
7676

7777
public async playSound(sound: Sound, allowManyInParallel = false): Promise<void> {
78+
console.log(sound.fileName, allowManyInParallel);
7879
if (!allowManyInParallel && this.playingSounds.has(sound)) {
7980
return;
8081
}
81-
82+
console.log('playing', sound.fileName);
8283
this.playingSounds.add(sound);
8384
const url = FileAccess.asBrowserUri(`vs/platform/audioCues/browser/media/${sound.fileName}`).toString(true);
8485

@@ -99,14 +100,16 @@ export class AudioCueService extends Disposable implements IAudioCueService {
99100
}
100101
}
101102

102-
public playAudioCueLoop(cue: AudioCue): IDisposable {
103+
public playAudioCueLoop(cue: AudioCue, milliseconds: number): IDisposable {
103104
let playing = true;
104105
const playSound = () => {
105106
if (playing) {
106107
this.playAudioCue(cue, true).finally(() => {
107-
if (playing) {
108-
playSound();
109-
}
108+
setTimeout(() => {
109+
if (playing) {
110+
playSound();
111+
}
112+
}, milliseconds);
110113
});
111114
}
112115
};

src/vs/workbench/contrib/chat/browser/chatWidget.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,13 +392,13 @@ export class ChatWidget extends Disposable implements IChatWidget {
392392
}
393393
this.audioCueService.playAudioCue(AudioCue.chatRequestSent, true);
394394
const input = query ?? editorValue;
395-
const cue = this.audioCueService.playAudioCueLoop(AudioCue.chatResponsePending);
395+
const cue = this.audioCueService.playAudioCueLoop(AudioCue.chatResponsePending, 7000);
396396
const result = await this.chatService.sendRequest(this.viewModel.sessionId, input);
397397
if (result) {
398398
this.inputPart.acceptInput(query);
399399
result.responseCompletePromise.then(async () => {
400400
cue?.dispose();
401-
this.audioCueService.playRandomAudioCue(AudioCueGroupId.chatResponseReceived);
401+
this.audioCueService.playRandomAudioCue(AudioCueGroupId.chatResponseReceived, true);
402402
const responses = this.viewModel?.getItems().filter(isResponseVM);
403403
const lastResponse = responses?.[responses.length - 1];
404404
if (lastResponse) {

0 commit comments

Comments
 (0)