add onAudioPlaybackStarted callback for controls (#3309)
* add onAudioTrackReady callback for controls * more details in controls.md for `onAudioPlaybackStarted`
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
} from "./livekit/MediaDevicesContext";
|
||||
import { type PrefetchedSounds } from "./soundUtils";
|
||||
import { useUrlParams } from "./UrlParams";
|
||||
import * as controls from "./controls";
|
||||
|
||||
/**
|
||||
* Play a sound though a given AudioContext. Will take
|
||||
@@ -42,6 +43,7 @@ async function playSound(
|
||||
src.buffer = buffer;
|
||||
src.connect(gain).connect(pan).connect(ctx.destination);
|
||||
const p = new Promise<void>((r) => src.addEventListener("ended", () => r()));
|
||||
controls.setPlaybackStarted();
|
||||
src.start();
|
||||
return p;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user