-
Notifications
You must be signed in to change notification settings - Fork 75
/
nativeMain.js
88 lines (73 loc) · 2.08 KB
/
nativeMain.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import initScene from './scene';
import bus from './bus';
var canvas = document.getElementById('scene');
// Canvas may not be available in test run
if (canvas) initVectorFieldApp(canvas);
// Tell webpack to split bundle, and download settings UI later.
require.ensure('@/vueApp.js', () => {
// Settings UI is ready, initialize vue.js application
require('@/vueApp.js');
});
function initVectorFieldApp(canvas) {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
var ctxOptions = {antialiasing: false };
var gl = canvas.getContext('webgl', ctxOptions) ||
canvas.getContext('experimental-webgl', ctxOptions);
if (gl) {
window.webgGLEnabled = true;
var scene = initScene(gl);
scene.start();
// TODO: too bad to plop stuff onto window?
window.scene = scene;
} else {
window.webgGLEnabled = false;
}
}
var CCapture;
var currentCapturer;
window.startRecord = startRecord;
window.isRecording = false;
function startRecord(url) {
if (!CCapture) {
require.ensure('ccapture.js', () => {
CCapture = require('ccapture.js');
window.stopRecord = stopRecord;
startRecord(url);
});
return;
}
if (currentCapturer) {
currentCapturer.stop();
}
if (!ffmpegScriptLoaded()) {
var ffmpegServer = document.createElement('script');
ffmpegServer.setAttribute('src', url || 'http://localhost:8080/ffmpegserver/ffmpegserver.js');
ffmpegServer.onload = () => startRecord(url);
document.head.appendChild(ffmpegServer);
return;
}
currentCapturer = new CCapture( {
format: 'ffmpegserver',
framerate: 60,
verbose: true,
name: "fieldplay",
extension: ".mp4",
codec: "mpeg4",
ffmpegArguments: [
"-b:v", "12M",
],
});
window.isRecording = true;
currentCapturer.start();
bus.fire('start-record', currentCapturer)
}
function ffmpegScriptLoaded() {
return typeof FFMpegServer !== 'undefined'
}
function stopRecord() {
window.isRecording = false;
bus.fire('stop-record', currentCapturer)
currentCapturer.stop();
currentCapturer.save();
}