Skip to content

Commit

Permalink
Merge remote-tracking branch 'msky/develop' into enh-9403
Browse files Browse the repository at this point in the history
  • Loading branch information
kakkokari-gtyih committed Nov 26, 2023
2 parents ce1de0f + 755ca97 commit bf63393
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- Fix: ウィジェットのジョブキューにて音声の発音方法変更に追従できていなかったのを修正 #12367
- Fix: コードエディタが正しく表示されない問題を修正
- Fix: プロフィールの「ファイル」にセンシティブな画像がある際のデザインを修正
- Fix: 一度に大量の通知が入った際に通知音が音割れする問題を修正

### Server
- Enhance: MFM `$[ruby ]` が他ソフトウェアと連合されるように
Expand Down
13 changes: 10 additions & 3 deletions packages/frontend/src/scripts/sound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as os from '@/os.js';

const ctx = new AudioContext();
const cache = new Map<string, AudioBuffer>();
let canPlay = true;

export const soundsTypes = [
null,
Expand Down Expand Up @@ -71,7 +72,7 @@ export const operationTypes = [
'antenna',
'channel',
'notification',
'reaction',
'reaction',
] as const;

export type SoundType = typeof soundsTypes[number];
Expand Down Expand Up @@ -134,16 +135,22 @@ export async function loadAudio(options: { soundType: SoundType, fileId?: string
return audioBuffer;
}


export function play(type: OperationType) {
const sound = defaultStore.state[`sound_${type}`];
if (_DEV_) console.log('play', type, sound);
if (sound.type == null) return;
if (sound.type == null || !canPlay) return;

canPlay = false;
playFile({
soundType: sound.type,
fileId: sound.fileId,
fileUrl: sound.fileUrl,
volume: sound.volume,
}).then(() => {
// ごく短時間に音が重複しないように
setTimeout(() => {
canPlay = true;
}, 25);
});
}

Expand Down

0 comments on commit bf63393

Please sign in to comment.