mirror of
https://github.com/Tonejs/Tone.js
synced 2025-01-12 03:48:49 +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();
|
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 () => {
|
it("can be stopped after starting", async () => {
|
||||||
const rec = new Recorder();
|
const rec = new Recorder();
|
||||||
rec.start();
|
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.
|
* when the recorder has started.
|
||||||
*/
|
*/
|
||||||
async start() {
|
async start() {
|
||||||
|
@ -121,8 +121,11 @@ export class Recorder extends ToneAudioNode<RecorderOptions> {
|
||||||
|
|
||||||
this._recorder.addEventListener("start", handleStart, false);
|
this._recorder.addEventListener("start", handleStart, false);
|
||||||
});
|
});
|
||||||
|
if(this.state === "stopped") {
|
||||||
this._recorder.start();
|
this._recorder.start();
|
||||||
|
} else {
|
||||||
|
this._recorder.resume();
|
||||||
|
}
|
||||||
return await startPromise;
|
return await startPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue