@@ -30,12 +30,27 @@ const styles={
30
30
color : "#258df2" ,
31
31
} ,
32
32
}
33
- const resolutionSize = {
34
- 1 : [ ] ,
35
- 2 : [ 1920 , 1080 ] ,
36
- 3 : [ 1280 , 720 ] ,
37
- 4 : [ 640 , 480 ]
38
- }
33
+ let VideoResolutions = [
34
+ { width : 4096 , height :2160 } ,
35
+ { width : 3840 , height :2160 } ,
36
+ { width : 2560 , height :1440 } ,
37
+ { width : 1920 , height :1200 } ,
38
+ { width : 1920 , height :1080 } ,
39
+ { width : 1280 , height :1000 } ,
40
+ { width : 1280 , height :900 } ,
41
+ { width : 1280 , height :800 } ,
42
+ { width : 1280 , height :768 } ,
43
+ { width : 1280 , height :720 } ,
44
+ { width : 1024 , height :576 } ,
45
+ { width : 768 , height :576 } ,
46
+ { width : 640 , height :480 } ,
47
+ { width : 640 , height :360 } ,
48
+ { width : 320 , height :240 } ,
49
+ { width : 320 , height :180 } ,
50
+ { width : 160 , height :120 }
51
+ ] ;
52
+
53
+ let MAX_RESOLUTION = { width : 1280 , height : 768 } ;
39
54
const theme = createMuiTheme ( {
40
55
palette : {
41
56
primary : {
@@ -181,7 +196,7 @@ class LiveInterview extends React.Component {
181
196
const __this = this ;
182
197
if ( ! isStopped )
183
198
{
184
- setTimeout ( function ( ) {
199
+ this . timer = setTimeout ( function ( ) {
185
200
const { remainingTime, timePos } = __this . state ;
186
201
let isStopped1 = __this . state . isStopped ;
187
202
console . log ( '===== Live: coutnDown: timePos: ' , timePos )
@@ -213,6 +228,10 @@ class LiveInterview extends React.Component {
213
228
remainingTime : newRemaining
214
229
} ) ;
215
230
}
231
+ if ( __this . timer && __this . timer != - 1 ) {
232
+ clearTimeout ( __this . timer ) ;
233
+ __this . timer = - 1 ;
234
+ }
216
235
__this . countDown ( )
217
236
}
218
237
} , 1000 )
@@ -222,9 +241,16 @@ class LiveInterview extends React.Component {
222
241
requestUserMedia ( ) {
223
242
const { resolution, frameRate } = this . state ;
224
243
let options = { mandatory : { } } ;
225
- if ( resolution !== 1 ) {
226
- options [ 'mandatory' ] [ 'minWidth' ] = resolutionSize [ resolution ] [ 0 ] ;
227
- options [ 'mandatory' ] [ 'minHeight' ] = resolutionSize [ resolution ] [ 1 ] ;
244
+ if ( resolution !== - 1 ) {
245
+ options [ 'mandatory' ] [ 'minWidth' ] = VideoResolutions [ resolution ] [ 'width' ] ;
246
+ options [ 'mandatory' ] [ 'minHeight' ] = VideoResolutions [ resolution ] [ 'height' ] ;
247
+ }
248
+ else {
249
+ if ( ! options [ 'video' ] ) {
250
+ options [ 'video' ] = { } ;
251
+ }
252
+ options [ 'video' ] [ 'width' ] = { ideal : VideoResolutions [ 0 ] [ 'width' ] } ;
253
+ options [ 'video' ] [ 'height' ] = { ideal : VideoResolutions [ 0 ] [ 'height' ] } ;
228
254
}
229
255
if ( frameRate !== 0 ) {
230
256
options [ 'mandatory' ] [ 'minFrameRate' ] = frameRate ;
@@ -256,7 +282,11 @@ class LiveInterview extends React.Component {
256
282
timePos : 1 ,
257
283
remainingTime : remainingTime
258
284
} ,
259
- function ( ) {
285
+ ( ) => {
286
+ if ( this . timer && this . timer != - 1 ) {
287
+ clearTimeout ( this . timer ) ;
288
+ this . timer = - 1 ;
289
+ }
260
290
this . countDown ( ) ;
261
291
this . videoRecordStart ( ) ;
262
292
}
@@ -279,9 +309,16 @@ class LiveInterview extends React.Component {
279
309
mimeType : mimeType ,
280
310
type : "video"
281
311
}
282
- if ( resolution !== 1 ) {
283
- options [ 'mandatory' ] [ 'minWidth' ] = resolutionSize [ resolution ] [ 0 ] ;
284
- options [ 'mandatory' ] [ 'minHeight' ] = resolutionSize [ resolution ] [ 1 ] ;
312
+ if ( resolution !== - 1 ) {
313
+ options [ 'mandatory' ] [ 'minWidth' ] = VideoResolutions [ resolution ] [ 'width' ] ;
314
+ options [ 'mandatory' ] [ 'minHeight' ] = VideoResolutions [ resolution ] [ 'height' ] ;
315
+ }
316
+ else {
317
+ if ( ! options [ 'video' ] ) {
318
+ options [ 'video' ] = { } ;
319
+ }
320
+ options [ 'video' ] [ 'width' ] = { ideal : VideoResolutions [ 0 ] [ 'width' ] } ;
321
+ options [ 'video' ] [ 'height' ] = { ideal : VideoResolutions [ 0 ] [ 'height' ] } ;
285
322
}
286
323
if ( frameRate !== 0 ) {
287
324
options [ 'mandatory' ] [ 'minFrameRate' ] = frameRate ;
@@ -332,6 +369,10 @@ class LiveInterview extends React.Component {
332
369
isPlaying : false ,
333
370
timePos : 0
334
371
} , function ( ) {
372
+ if ( __this . timer && __this . timer != - 1 ) {
373
+ clearTimeout ( __this . timer ) ;
374
+ __this . timer = - 1 ;
375
+ }
335
376
__this . countDown ( ) ;
336
377
} ) ;
337
378
} ;
@@ -346,7 +387,11 @@ class LiveInterview extends React.Component {
346
387
isStopped : false ,
347
388
isPlaying : false ,
348
389
timePos : 0
349
- } , function ( ) {
390
+ } , ( ) => {
391
+ if ( __this . timer && __this . timer != - 1 ) {
392
+ clearTimeout ( __this . timer ) ;
393
+ __this . timer = - 1 ;
394
+ }
350
395
__this . countDown ( ) ;
351
396
} ) ;
352
397
} ;
0 commit comments