()
| 438 | }; |
| 439 | |
| 440 | function drawVideosToCanvas() { |
| 441 | if (isStopDrawingFrames) { |
| 442 | return; |
| 443 | } |
| 444 | |
| 445 | var videosLength = videos.length; |
| 446 | |
| 447 | var fullcanvas = false; |
| 448 | var remaining = []; |
| 449 | videos.forEach(function(video) { |
| 450 | if (!video.stream) { |
| 451 | video.stream = {}; |
| 452 | } |
| 453 | |
| 454 | if (video.stream.fullcanvas) { |
| 455 | fullcanvas = video; |
| 456 | } else { |
| 457 | remaining.push(video); |
| 458 | } |
| 459 | }); |
| 460 | |
| 461 | if (fullcanvas) { |
| 462 | canvas.width = fullcanvas.stream.width; |
| 463 | canvas.height = fullcanvas.stream.height; |
| 464 | } else if (remaining.length) { |
| 465 | canvas.width = videosLength > 1 ? remaining[0].width * 2 : remaining[0].width; |
| 466 | canvas.height = videosLength > 2 ? remaining[0].height * 2 : remaining[0].height; |
| 467 | } else { |
| 468 | canvas.width = self.width || 360; |
| 469 | canvas.height = self.height || 240; |
| 470 | } |
| 471 | |
| 472 | if (fullcanvas && fullcanvas instanceof HTMLVideoElement) { |
| 473 | drawImage(fullcanvas); |
| 474 | } |
| 475 | |
| 476 | remaining.forEach(function(video, idx) { |
| 477 | drawImage(video, idx); |
| 478 | }); |
| 479 | |
| 480 | setTimeout(drawVideosToCanvas, self.frameInterval); |
| 481 | } |
| 482 | |
| 483 | function drawImage(video, idx) { |
| 484 | if (isStopDrawingFrames) { |
no test coverage detected