-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmedia-recorder-js.d.ts
133 lines (117 loc) · 3.7 KB
/
media-recorder-js.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
declare module 'media-recorder-js' {
interface QBMediaRecorderConstructorProps {
/** Preferred MIME type */
mimeType?: string
workerPath?: string
/**
* The minimum number of milliseconds of data to return
* in a single Blob, fire 'ondataavaible' callback
* (isn't need to use with 'audio/wav' of 'audio/mp3')
*
* @default 1000
*/
timeslice?: number
/**
* What to do with a muted input MediaStreamTrack,
* e.g. insert black frames/zero audio volume in the recording
* or ignore altogether
*
* @default true
*/
ignoreMutedMedia?: boolean
/** Recording start event handler */
onstart?: VoidFunction
/** Recording stop event handler */
onstop?: (file: Blob) => void
/** Recording pause event handler */
onpause?: VoidFunction
/** Recording resume event handler */
onresume?: VoidFunction
/** Error event handler */
onerror?: (error: unknown) => void
/**
* `dataavailable` event handler.
* The Blob of recorded data is contained in this event (callback
* isn't supported if use 'audio/wav' of 'audio/mp3' for recording)
*/
ondataavailable?: (event: { data: Blob }) => void
}
class QBMediaRecorder {
constructor(config: QBMediaRecorderConstructorProps)
/**
* Switch recording Blob objects to the specified
* MIME type if `MediaRecorder` support it.
*/
toggleMimeType(mimeType: string): void
/**
* Returns current `MediaRecorder` state
*/
getState(): 'inactive' | 'recording' | 'paused'
/**
* Starts recording a stream.
* Fires `onstart` callback.
*/
start(stream: MediaStream): void
/**
* Stops recording a stream
*
* @fires `onstop` callback and passing there Blob recorded
*/
stop(): void
/** Pausing stream recording */
pause(): void
/** Resumes stream recording */
resume(): void
/**
* Change record source
*/
change(stream: MediaStream): void
/**
* Create a file from blob and download as file.
* This method will call `stop` if recording is in progress.
*
* @param {string} filename Name of video file to be downloaded
* (default to `Date.now()`)
*/
download(filename?: string): void
_getBlobRecorded(): Blob
callbacks: Pick<
QBMediaRecorderConstructorProps,
| 'onstart'
| 'onstop'
| 'onpause'
| 'onresume'
| 'ondataavailable'
| 'onerror'
>
/**
* Checks capability of recording in the environment.
* Checks `MediaRecorder`, `MediaRecorder.isTypeSupported` and `Blob`.
*/
static isAvailable(): boolean
/**
* Checks if AudioContext API is available.
* Checks `window.AudioContext` or `window.webkitAudioContext`.
*/
static isAudioContext(): boolean
/**
* The `QBMediaRecorder.isTypeSupported()` static method returns
* a Boolean which is true if the MIME type specified is one
* the user agent should be able to successfully record.
* @param mimeType The MIME media type to check.
*
* @returns true if the `MediaRecorder` implementation is capable of
* recording `Blob` objects for the specified MIME type. Recording may
* still fail if there are insufficient resources to support the
* recording and encoding process. If the value is false, the user
* agent is incapable of recording the specified format.
*/
static isTypeSupported(mimeType: string): boolean
/**
* Return supported mime types
* @param type video or audio (dafault to 'video')
*/
static getSupportedMimeTypes(type: 'audio' | 'video' = 'video'): string[]
}
export default QBMediaRecorder
}