@m2c2kit/core 0.3.26 → 0.3.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +39 -0
- package/dist/index.js +70 -2
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -4739,10 +4739,49 @@ declare class SoundRecorder extends M2Node implements Omit<SoundRecorderOptions,
|
|
|
4739
4739
|
*/
|
|
4740
4740
|
constructor(options?: SoundRecorderOptions);
|
|
4741
4741
|
initialize(): void;
|
|
4742
|
+
/**
|
|
4743
|
+
* Starts recording audio from the microphone.
|
|
4744
|
+
*
|
|
4745
|
+
* @remarks If the `SoundRecorder` is already recording, an error will be
|
|
4746
|
+
* thrown. If permission to use the microphone has not been granted, the
|
|
4747
|
+
* browser will prompt the user to allow or deny access. Denial of access
|
|
4748
|
+
* will result in an error being thrown. To avoid this, use the
|
|
4749
|
+
* `queryPermission()` and `requestPermission()` methods to check and request
|
|
4750
|
+
* permission, respectively, and handle the results accordingly.
|
|
4751
|
+
*/
|
|
4742
4752
|
start(): Promise<void>;
|
|
4753
|
+
/**
|
|
4754
|
+
* Stops recording audio from the microphone.
|
|
4755
|
+
*
|
|
4756
|
+
* @remarks If the `stop()` method is not awaited, the method returns a
|
|
4757
|
+
* Promise and the useable data will be lost.
|
|
4758
|
+
*
|
|
4759
|
+
* @returns A promise that resolves to a {@link SoundRecorderResults} object.
|
|
4760
|
+
* The `audioBase64` property of the object contains the recorded audio as a
|
|
4761
|
+
* base64 string.
|
|
4762
|
+
*/
|
|
4743
4763
|
stop(): Promise<SoundRecorderResults>;
|
|
4744
4764
|
pause(): void;
|
|
4745
4765
|
resume(): void;
|
|
4766
|
+
/**
|
|
4767
|
+
* Checks if the microphone permission is granted.
|
|
4768
|
+
*
|
|
4769
|
+
* @remarks This does not request permission from the user. It only queries
|
|
4770
|
+
* the current microphone permission state.
|
|
4771
|
+
*
|
|
4772
|
+
* @returns The `state` property ("granted", "denied", or "prompt") of
|
|
4773
|
+
* `PermissionStatus` or undefined if the browser does not support the
|
|
4774
|
+
* "microphone" permission.
|
|
4775
|
+
* See https://developer.mozilla.org/en-US/docs/Web/API/PermissionStatus/state
|
|
4776
|
+
*/
|
|
4777
|
+
queryPermission(): Promise<string | undefined>;
|
|
4778
|
+
/**
|
|
4779
|
+
* Requests permission to use the microphone, and possibly prompts the user
|
|
4780
|
+
* to allow or deny access.
|
|
4781
|
+
*
|
|
4782
|
+
* @returns true if the microphone permission is granted, false if denied.
|
|
4783
|
+
*/
|
|
4784
|
+
requestPermission(): Promise<boolean>;
|
|
4746
4785
|
/** Is the `SoundRecorder` currently recording? */
|
|
4747
4786
|
get isRecording(): boolean;
|
|
4748
4787
|
/** Is the `SoundRecorder` currently paused? */
|
package/dist/index.js
CHANGED
|
@@ -11855,12 +11855,24 @@ class SoundRecorder extends M2Node {
|
|
|
11855
11855
|
}
|
|
11856
11856
|
initialize() {
|
|
11857
11857
|
}
|
|
11858
|
+
/**
|
|
11859
|
+
* Starts recording audio from the microphone.
|
|
11860
|
+
*
|
|
11861
|
+
* @remarks If the `SoundRecorder` is already recording, an error will be
|
|
11862
|
+
* thrown. If permission to use the microphone has not been granted, the
|
|
11863
|
+
* browser will prompt the user to allow or deny access. Denial of access
|
|
11864
|
+
* will result in an error being thrown. To avoid this, use the
|
|
11865
|
+
* `queryPermission()` and `requestPermission()` methods to check and request
|
|
11866
|
+
* permission, respectively, and handle the results accordingly.
|
|
11867
|
+
*/
|
|
11858
11868
|
async start() {
|
|
11859
11869
|
if (this.isRecording) {
|
|
11860
11870
|
throw new Error(
|
|
11861
11871
|
"cannot start SoundRecorder because it is already started."
|
|
11862
11872
|
);
|
|
11863
11873
|
}
|
|
11874
|
+
this.audioChunks = [];
|
|
11875
|
+
this.endIso8601Timestamp = void 0;
|
|
11864
11876
|
const supportedMimeTypes = this.getMediaRecorderSupportedAudioMimeTypes();
|
|
11865
11877
|
if (supportedMimeTypes.length === 0) {
|
|
11866
11878
|
throw new Error(
|
|
@@ -11877,7 +11889,7 @@ class SoundRecorder extends M2Node {
|
|
|
11877
11889
|
audio: this.audioTrackConstraints ? this.audioTrackConstraints : true
|
|
11878
11890
|
});
|
|
11879
11891
|
} catch (error) {
|
|
11880
|
-
throw new Error(
|
|
11892
|
+
throw new Error(`Error getting user media: ${error}.`);
|
|
11881
11893
|
}
|
|
11882
11894
|
if (!stream) {
|
|
11883
11895
|
throw new Error("no stream.");
|
|
@@ -11900,6 +11912,16 @@ class SoundRecorder extends M2Node {
|
|
|
11900
11912
|
this._isRecording = true;
|
|
11901
11913
|
this._isPaused = false;
|
|
11902
11914
|
}
|
|
11915
|
+
/**
|
|
11916
|
+
* Stops recording audio from the microphone.
|
|
11917
|
+
*
|
|
11918
|
+
* @remarks If the `stop()` method is not awaited, the method returns a
|
|
11919
|
+
* Promise and the useable data will be lost.
|
|
11920
|
+
*
|
|
11921
|
+
* @returns A promise that resolves to a {@link SoundRecorderResults} object.
|
|
11922
|
+
* The `audioBase64` property of the object contains the recorded audio as a
|
|
11923
|
+
* base64 string.
|
|
11924
|
+
*/
|
|
11903
11925
|
async stop() {
|
|
11904
11926
|
if (!this.isRecording) {
|
|
11905
11927
|
throw new Error("cannot stop SoundRecorder because it has not started.");
|
|
@@ -11959,6 +11981,52 @@ class SoundRecorder extends M2Node {
|
|
|
11959
11981
|
this._isPaused = false;
|
|
11960
11982
|
Timer.start(this.timerUuid);
|
|
11961
11983
|
}
|
|
11984
|
+
/**
|
|
11985
|
+
* Checks if the microphone permission is granted.
|
|
11986
|
+
*
|
|
11987
|
+
* @remarks This does not request permission from the user. It only queries
|
|
11988
|
+
* the current microphone permission state.
|
|
11989
|
+
*
|
|
11990
|
+
* @returns The `state` property ("granted", "denied", or "prompt") of
|
|
11991
|
+
* `PermissionStatus` or undefined if the browser does not support the
|
|
11992
|
+
* "microphone" permission.
|
|
11993
|
+
* See https://developer.mozilla.org/en-US/docs/Web/API/PermissionStatus/state
|
|
11994
|
+
*/
|
|
11995
|
+
async queryPermission() {
|
|
11996
|
+
try {
|
|
11997
|
+
const status = await navigator.permissions.query({
|
|
11998
|
+
/**
|
|
11999
|
+
* We use a type assertion here because the PermissionName type
|
|
12000
|
+
* does not include "microphone" in the TypeScript type definitions.
|
|
12001
|
+
*/
|
|
12002
|
+
name: "microphone"
|
|
12003
|
+
});
|
|
12004
|
+
return status.state;
|
|
12005
|
+
} catch (error) {
|
|
12006
|
+
console.warn(
|
|
12007
|
+
`Error calling navigator.permissions.query({ name: "microphone" }): ${error}.`
|
|
12008
|
+
);
|
|
12009
|
+
return void 0;
|
|
12010
|
+
}
|
|
12011
|
+
}
|
|
12012
|
+
/**
|
|
12013
|
+
* Requests permission to use the microphone, and possibly prompts the user
|
|
12014
|
+
* to allow or deny access.
|
|
12015
|
+
*
|
|
12016
|
+
* @returns true if the microphone permission is granted, false if denied.
|
|
12017
|
+
*/
|
|
12018
|
+
async requestPermission() {
|
|
12019
|
+
try {
|
|
12020
|
+
const stream = await navigator.mediaDevices.getUserMedia({
|
|
12021
|
+
audio: this.audioTrackConstraints ? this.audioTrackConstraints : true
|
|
12022
|
+
});
|
|
12023
|
+
stream.getTracks().forEach((track) => track.stop());
|
|
12024
|
+
return true;
|
|
12025
|
+
} catch (error) {
|
|
12026
|
+
console.warn(`Microphone access denied: ${error}`);
|
|
12027
|
+
return false;
|
|
12028
|
+
}
|
|
12029
|
+
}
|
|
11962
12030
|
/** Is the `SoundRecorder` currently recording? */
|
|
11963
12031
|
get isRecording() {
|
|
11964
12032
|
return this._isRecording;
|
|
@@ -12112,7 +12180,7 @@ class Story {
|
|
|
12112
12180
|
}
|
|
12113
12181
|
}
|
|
12114
12182
|
|
|
12115
|
-
console.log("\u26AA @m2c2kit/core version 0.3.
|
|
12183
|
+
console.log("\u26AA @m2c2kit/core version 0.3.27 (1ed4ac2a)");
|
|
12116
12184
|
|
|
12117
12185
|
export { Action, ActivityType, CanvasKitHelpers, ColorfulMutablePath, Composite, Constants, ConstraintType, CustomAction, Dimensions, Easings, Equal, Equals, EventStore, EventStoreMode, FadeAlphaAction, FontManager, Game, GroupAction, I18n, ImageManager, Label, LabelHorizontalAlignmentMode, LayoutConstraint, LegacyTimer, M2EventType, M2ImageStatus, M2Node, M2NodeFactory, M2NodeType, M2SoundStatus, M2c2KitHelpers, MoveAction, MutablePath, NoneTransition, PlayAction, RandomDraws, RepeatAction, RepeatForeverAction, RotateAction, ScaleAction, Scene, SceneTransition, SequenceAction, Shape, ShapeType, SlideTransition, SoundManager, SoundPlayer, SoundRecorder, Sprite, Story, TextLine, Timer, Transition, TransitionDirection, TransitionType, Uuid, WaitAction, WebColors, WebGlInfo, handleInterfaceOptions };
|
|
12118
12186
|
//# sourceMappingURL=index.js.map
|