marcelle.fileUpload(): fileUpload;
A file upload component, that creates a stream of files.
| Name | Type | Description | Hold |
|---|
| $files | Stream<never()> | Stream of files | |
const myFileUpload = marcelle.fileUpload();
myFileUpload.$files.subscribe((x) => console.log('fileUpload $files:', x));
marcelle.imageUpload({ width?: number, height?: number }): ImageUpload;
An Image upload component, that creates a stream of images and thumbnails. Images are cropped and rescaled to match the target dimensions, if these are non-zero, otherwise the dimensions are unchanged.
| Option | Type | Description | Required | Default |
|---|
| width | number | Target image width | | 0 |
| height | number | Target image height | | 0 |
| Name | Type | Description | Hold |
|---|
| $images | Stream<ImageData> | Stream of images in the ImageData format. | |
| $thumbnails | Stream<string> | Stream of thumbnail images in base64 dataURI format. | |
const imgUpload = marcelle.imageUpload();
imgUpload.$images.subscribe((x) => console.log('imageUpload $images:', x));
marcelle.mediaRecorder(mediaStream: MediaStream): MediaRecorder;
A generic recording component for audio/visual data, that works both for audio and video. The component can be used, for instance, with the microphone and webcam components.
| Option | Type | Description | Required | Default |
|---|
| mediaStream | MediaStream | MediaStream from which to record | | 0 |
The MediaStream can be obtained from the microphone and webcam component through their mediastream stream.
| Name | Type | Description | Hold |
|---|
| $mediaStream | Stream<MediaStream> | Stream of MediaStream to specify the source of recordings dynamically | |
| $active | Stream<boolean> | Stream specifying the recording status, that can be used to toggle recording | |
| $recordings | Stream<IRecording> | Stream of recordings produced by the component. A new event occurs whenever the recording is stopped. | |
Each event in the stream of recordings has the following interface:
$recordings: Stream<{
duration: number;
blob: Blob;
type: string;
thumbnail: string;
}>;
const input = webcam({ audio: true });
const recorder = mediaRecorder();
recorder.$mediaStream = input.$mediastream;
recorder.$recordings.subscribe(console.log);
marcelle.microphone(): Microphone;
A microphone source component.
| Name | Type | Description | Hold |
|---|
| $active | Stream<boolean> | Boolean stream specifying if the webcam is active (streaming) | |
| $ready | Stream<boolean> | Boolean stream specifying if the webcam is ready | |
| $mediastream | Stream<MediaStream> | Stream of MediaStream corresponding to the selected microphone. Events are emitted whenever a device is selected. | |
marcelle.sketchpad(): Sketchpad;
An input sketching component allowing the user to draw. The generate generates a stream of images of the sketches, as well as stream for various user actions.
| Name | Type | Description | Hold |
|---|
| $images | Stream<ImageData> | Stream of images in the ImageData format. | |
| $thumbnails | Stream<string> | Stream of thumbnail images in base64 dataURI format. | |
| $strokeStart | Stream<undefined> | Stream of empty (undefined) events occurring every time the user starts drawing | |
| $strokeEnd | Stream<undefined> | Stream of empty (undefined) events occurring every time the user stops drawing | |
const sketch = marcelle.sketchpad();
sketch.$strokeStart.subscribe(() => console.log('sketchpad $strokeStart'));
sketch.$strokeEnd.subscribe(() => console.log('sketchpad $strokeEnd'));
marcelle.webcam({ width?: number, height?: number, period?: number }): Webcam;
A webcam source component, producing a periodic stream of images.
| Option | Type | Description | Required | Default |
|---|
| width | number | The target image width | | 224 |
| height | number | The target image height | | 224 |
| period | number | The period in ms at which images are sampled | | 50 |
| Name | Type | Description | Hold |
|---|
| $images | Stream<ImageData> | Stream of images in the ImageData format. | |
| $thumbnails | Stream<string> | Stream of thumbnail images in base64 dataURI format. | |
| $active | Stream<boolean> | Boolean stream specifying if the webcam is active (streaming) | |
| $ready | Stream<boolean> | Boolean stream specifying if the webcam is ready | |
| $mediastream | Stream<MediaStream> | Stream of MediaStream corresponding to the selected webcam. Events are emitted whenever a webcam is selected. | |
const webcam = marcelle.webcam();
webcam.$images.subscribe((x) => console.log('webcam $images:', x));