mirror of
https://github.com/Tonejs/Tone.js
synced 2025-01-11 19:38:47 +00:00
Recorder resumes if start() is called in paused state
This commit is contained in:
parent
3fee7e9976
commit
45718b17d9
2 changed files with 19 additions and 3 deletions
|
@ -68,6 +68,19 @@ describe("Recorder", () => {
|
|||
rec.dispose();
|
||||
});
|
||||
|
||||
it("can be resumed after pausing", async () => {
|
||||
const rec = new Recorder();
|
||||
rec.start();
|
||||
expect(rec.state).to.equal("started");
|
||||
await wait(100);
|
||||
rec.pause();
|
||||
expect(rec.state).to.equal("paused");
|
||||
await wait(100);
|
||||
rec.start();
|
||||
expect(rec.state).to.equal("started");
|
||||
rec.dispose();
|
||||
});
|
||||
|
||||
it("can be stopped after starting", async () => {
|
||||
const rec = new Recorder();
|
||||
rec.start();
|
||||
|
|
|
@ -107,7 +107,7 @@ export class Recorder extends ToneAudioNode<RecorderOptions> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Start the Recorder. Returns a promise which resolves
|
||||
* Start/Resume the Recorder. Returns a promise which resolves
|
||||
* when the recorder has started.
|
||||
*/
|
||||
async start() {
|
||||
|
@ -121,8 +121,11 @@ export class Recorder extends ToneAudioNode<RecorderOptions> {
|
|||
|
||||
this._recorder.addEventListener("start", handleStart, false);
|
||||
});
|
||||
|
||||
this._recorder.start();
|
||||
if(this.state === "stopped") {
|
||||
this._recorder.start();
|
||||
} else {
|
||||
this._recorder.resume();
|
||||
}
|
||||
return await startPromise;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue