Skip to content

Commit 885da71

Browse files
committed
fix: alertplayer currently playing
1 parent 42050e7 commit 885da71

2 files changed

Lines changed: 15 additions & 12 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "hehe-chat",
33
"private": true,
4-
"version": "0.38.1",
4+
"version": "0.38.2",
55
"scripts": {
66
"dev": "vite",
77
"build": "tsc && vite build",

src/components/alerts/alertplayer.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,8 @@ class AlertPlayer {
933933
eventData: any;
934934
skipReason?: string;
935935
}) {
936+
this.currentlyPlaying = event;
937+
936938
const onEnd = () => {
937939
console.log('Stop Playing');
938940
this.stopPlaying();
@@ -961,11 +963,12 @@ class AlertPlayer {
961963

962964
this.startPlaying();
963965
// Direct access to blerp audio without proxy
964-
this.getAudioInfo(alertInfo.audioUrl!).then((audioInfo) => {
965-
PubSub.publish('AlertPlayer-update', {duration: audioInfo?.duration || 5}); // Default to 5 seconds if duration unknown
966-
this.playAudio(1.0, audioInfo, 0).then(onEnd, onError);
967-
}, onError);
968-
return;
966+
return new Promise<void>((resolve, reject) => {
967+
this.getAudioInfo(alertInfo.audioUrl!).then((audioInfo) => {
968+
PubSub.publish('AlertPlayer-update', {duration: audioInfo?.duration || 5});
969+
this.playAudio(1.0, audioInfo, 0).then(() => { onEnd(); resolve(); }, (err) => { onError(err); reject(err); });
970+
}, (err) => { onError(err); reject(err); });
971+
});
969972
}
970973

971974
// Handle soundalerts (direct audio URL)
@@ -982,11 +985,12 @@ class AlertPlayer {
982985
}
983986

984987
this.startPlaying();
985-
this.getAudioInfo(alertInfo.audioUrl!).then((audioInfo) => {
986-
PubSub.publish('AlertPlayer-update', {duration: audioInfo?.duration || 5});
987-
this.playAudio(1.0, audioInfo, 0).then(onEnd, onError);
988-
}, onError);
989-
return;
988+
return new Promise<void>((resolve, reject) => {
989+
this.getAudioInfo(alertInfo.audioUrl!).then((audioInfo) => {
990+
PubSub.publish('AlertPlayer-update', {duration: audioInfo?.duration || 5});
991+
this.playAudio(1.0, audioInfo, 0).then(() => { onEnd(); resolve(); }, (err) => { onError(err); reject(err); });
992+
}, (err) => { onError(err); reject(err); });
993+
});
990994
}
991995

992996
// At this point we have a standard alert
@@ -1014,7 +1018,6 @@ class AlertPlayer {
10141018
const sink = localStorage.getItem('hehe-sink') || '';
10151019
this.startPlaying();
10161020
console.log('Start playing');
1017-
this.currentlyPlaying = event;
10181021
const ttsMessage = this.cleanMessage(formatString(alert.audio?.tts?.text || "", {
10191022
...vars,
10201023
text: (eventData && eventData.text) ? this.parsedPartsToTTSText(eventData.text.parts || eventData.text) : undefined

0 commit comments

Comments
 (0)