Skip to content

Commit a4e58aa

Browse files
v0.4.5
1 parent 7168f88 commit a4e58aa

31 files changed

+2459
-1717
lines changed

media-recorder-js.d.ts

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

package-lock.json

Lines changed: 30 additions & 58 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "quickblox-react-ui-kit",
3-
"version": "0.4.1",
3+
"version": "0.4.5",
44
"main": "dist/index-ui.js",
55
"license": "MIT",
66
"dependencies": {
@@ -12,7 +12,8 @@
1212
"qb-ai-core": "^0.1.3",
1313
"qb-ai-rephrase": "^0.1.2",
1414
"qb-ai-translate": "^0.1.2",
15-
"quickblox": "^2.17.0",
15+
"quickblox": "^2.19.2",
16+
"media-recorder-js": "^2.1.0",
1617
"react": "^18.2.0",
1718
"react-dom": "^18.2.0",
1819
"react-router-dom": "^6.11.1",

src/App.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,16 @@ import useQbUIKitDataContext from './Presentation/providers/QuickBloxUIKitProvid
1717
import { QBConfig } from './QBconfig';
1818

1919
function App() {
20-
// const currentContext = React.useContext(qbDataContext);
20+
if ((window as any).QB === undefined) {
21+
if (QB !== undefined) {
22+
(window as any).QB = QB;
23+
} else {
24+
// eslint-disable-next-line @typescript-eslint/no-var-requires,global-require
25+
const QBLib = require('quickblox/quickblox.min');
26+
27+
(window as any).QB = QBLib;
28+
}
29+
}
2130
const currentContext = useQbUIKitDataContext();
2231

2332
const remoteDataSource: RemoteDataSource =

0 commit comments

Comments
 (0)