@@ -11,13 +11,14 @@ The library contains only one script `fix-webm-duration.js` and has no dependenc
11
11
Syntax:
12
12
13
13
``` javascript
14
- ysFixWebmDuration (blob, duration, callback, options = {});
14
+ ysFixWebmDuration (blob, duration, callback = undefined , options = {});
15
15
```
16
16
17
17
where
18
18
- ` blob ` is ` Blob ` object with file contents from ` MediaRecorder `
19
19
- ` duration ` is video duration in milliseconds (you should calculate it while recording the video)
20
- - ` callback ` is callback function that will receive fixed blob
20
+ - ` callback ` is callback function that will receive fixed blob.
21
+ If omitted, a ` Promise ` object will be returned instead.
21
22
- ` options ` is an object of options:
22
23
- ` options.logger ` - a callback for logging debug messages or ` false ` .
23
24
The callback should accept one argument - the message string.
@@ -41,10 +42,17 @@ function startRecording(stream, options) {
41
42
mediaRecorder .onstop = function () {
42
43
var duration = Date .now () - startTime;
43
44
var buggyBlob = new Blob (mediaParts, { type: ' video/webm' });
44
-
45
+
46
+ // v1: callback-style
45
47
ysFixWebmDuration (buggyBlob, duration, function (fixedBlob ) {
46
48
displayResult (fixedBlob);
47
49
});
50
+
51
+ // v2: promise-style, disable logging
52
+ ysFixWebmDuration (buggyBlob, duration, {logger: false })
53
+ .then (function (fixedBlob ) {
54
+ displayResult (fixedBlob);
55
+ });
48
56
};
49
57
mediaRecorder .ondataavailable = function (event ) {
50
58
var data = event .data ;
0 commit comments