Skip to content

Commit afa1ae7

Browse files
author
ninjadev999
committed
Fix video resolution, timer interval
1 parent ff209dc commit afa1ae7

File tree

1 file changed

+60
-15
lines changed
  • frontend/src/containers/talent/video-interview

1 file changed

+60
-15
lines changed

frontend/src/containers/talent/video-interview/live.js

Lines changed: 60 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,27 @@ const styles={
3030
color: "#258df2",
3131
},
3232
}
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};
3954
const theme = createMuiTheme ({
4055
palette: {
4156
primary: {
@@ -181,7 +196,7 @@ class LiveInterview extends React.Component {
181196
const __this = this;
182197
if (!isStopped)
183198
{
184-
setTimeout(function () {
199+
this.timer = setTimeout(function () {
185200
const { remainingTime, timePos } = __this.state;
186201
let isStopped1 = __this.state.isStopped;
187202
console.log('===== Live: coutnDown: timePos: ', timePos)
@@ -213,6 +228,10 @@ class LiveInterview extends React.Component {
213228
remainingTime: newRemaining
214229
});
215230
}
231+
if (__this.timer && __this.timer != -1) {
232+
clearTimeout(__this.timer);
233+
__this.timer = -1;
234+
}
216235
__this.countDown()
217236
}
218237
}, 1000)
@@ -222,9 +241,16 @@ class LiveInterview extends React.Component {
222241
requestUserMedia() {
223242
const { resolution, frameRate } = this.state;
224243
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'] };
228254
}
229255
if (frameRate !== 0){
230256
options['mandatory']['minFrameRate'] = frameRate;
@@ -256,7 +282,11 @@ class LiveInterview extends React.Component {
256282
timePos: 1,
257283
remainingTime: remainingTime
258284
},
259-
function() {
285+
() => {
286+
if (this.timer && this.timer != -1) {
287+
clearTimeout(this.timer);
288+
this.timer = -1;
289+
}
260290
this.countDown();
261291
this.videoRecordStart();
262292
}
@@ -279,9 +309,16 @@ class LiveInterview extends React.Component {
279309
mimeType: mimeType,
280310
type: "video"
281311
}
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'] };
285322
}
286323
if (frameRate !== 0){
287324
options['mandatory']['minFrameRate'] = frameRate;
@@ -332,6 +369,10 @@ class LiveInterview extends React.Component {
332369
isPlaying: false,
333370
timePos: 0
334371
}, function() {
372+
if (__this.timer && __this.timer != -1) {
373+
clearTimeout(__this.timer);
374+
__this.timer = -1;
375+
}
335376
__this.countDown();
336377
});
337378
};
@@ -346,7 +387,11 @@ class LiveInterview extends React.Component {
346387
isStopped: false,
347388
isPlaying: false,
348389
timePos: 0
349-
}, function() {
390+
}, () => {
391+
if (__this.timer && __this.timer != -1) {
392+
clearTimeout(__this.timer);
393+
__this.timer = -1;
394+
}
350395
__this.countDown();
351396
});
352397
};

0 commit comments

Comments
 (0)