-
Notifications
You must be signed in to change notification settings - Fork 0
/
SeriouslyWindow.html
175 lines (154 loc) · 6.44 KB
/
SeriouslyWindow.html
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Music Video Monster-Video Window</title>
</head>
<body>
<!-- 1. The <iframe> (and video player) will replace this <div> tag. -->
<div>
<canvas id="canvas" width="1600" height="900" webkitallowfullscreen mozallowfullscreen allowfullscreen></canvas>
</div>
<div>
<input type="Button" id="btnFullscreen" value="fullscreen">
<div id="current">0:00</div>
<div id="duration">0:00</div>
</div>
<!-- <video id="video" src="file://F:\Projects\electron-quick-start\Media\DIE ANTWOORD - BABY'S ON FIRE (OFFICIAL).mp4" autoplay> -->
<video id="video" style="display:none;" webkitallowfullscreen mozallowfullscreen allowfullscreen>
</video>
<script>
if (typeof module === 'object') {
window.module = module;
module = undefined;
}
</script>
<script src="node_modules/jquery/dist/jquery.js"></script>
<script>
if (window.module) module = window.module;
</script>
<script src="lib/Seriously/seriously.js"></script>
<script src="lib/Seriously/effects/seriously.vignette.js"></script>
<script src="lib/Seriously/effects/seriously.pixelate.js"></script>
<script src="lib/Seriously/effects/seriously.ascii.js"></script>
<script src="lib/Seriously/effects/seriously.tvglitch.js"></script>
<script src="lib/Seriously/effects/seriously.accumulator.js"></script>
<script src="lib/Seriously/effects/seriously.filmgrain.js"></script>
<script src="lib/Seriously/effects/seriously.invert.js"></script>
<script>
$(document).ready(function () {
const {ipcRenderer} = require('electron')
var video, canvas, seriously, reformat;
const fadeOutTime = 2;
$("#video").on("timeupdate", function (event) {
onTrackedVideoFrame(this.currentTime, this.duration);
});
function init() {
video = $('#video');
video[0].playbackRate = 1;
canvas = $('#canvas');
seriously = new Seriously();
reformat = seriously.transform('reformat');
var target = seriously.target('#canvas');
reformat.width = target.width;
reformat.height = target.height;
reformat.mode = 'cover';
reformat.source = seriously.source('#video');
target.source = reformat;
$('#btnFullscreen').click(function(){
canvas[0].webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
});
seriously.go();
}
function effect_ascii(invar, outvar) {
var ascii = seriously.effect('ascii');
ascii.source = invar;
outvar.source = ascii;
}
function effect_pixel(invar, outvar) {
var pixel = seriously.effect('pixelate');
pixel.source = invar;
outvar.source = pixel;
}
function effect_none(invar, outvar) {
outvar.source = invar;
}
function effect_tvglitch(invar, outvar) {
var effect = seriously.effect('tvglitch');
effect.source = invar;
outvar.source = effect;
}
function effect_filmgrain(invar, outvar) {
var effect = seriously.effect('filmgrain');
effect.source = invar;
outvar.source = effect;
}
function effect_invert(invar, outvar) {
var effect = seriously.effect('invert');
effect.source = invar;
outvar.source = effect;
}
function effect_accumulator(invar, outvar) {
console.log('accumulator effect')
var effect = seriously.effect('accumulator');
effect.source = invar;
effect.opacity = .5;
effect.blendMode = "normal";
outvar.source = effect;
}
ipcRenderer.on('video-param', (event, arg) => {
console.log(arg);
if (arg.fullscreen == true) {
full()
}
if (arg.effect != null) {
switch (arg.effect.type) {
case "ascii":
effect_ascii(seriously.source('#video'), reformat);
break;
case "pixel":
effect_pixel(seriously.source('#video'), reformat);
break;
case "tvglitch":
effect_tvglitch(seriously.source('#video'), reformat);
break;
case "accumulator":
effect_accumulator(seriously.source('#video'), reformat);
break;
case "filmgrain":
effect_filmgrain(seriously.source('#video'), reformat);
break;
case "invert":
effect_invert(seriously.source('#video'), reformat);
break;
default:
effect_none(seriously.source('#video'), reformat);
}
}
})
ipcRenderer.on('video-load', (event, arg) => {
var abspath = 'G:\\Projects\\YoutubeDownload\\' + arg
console.log(abspath) // prints "pong"
//var video = document.getElementById('video');
video[0].src = abspath
console.log(video)
video[0].load();
video[0].addEventListener("canplaythrough",function(){
this.play();
});
})
ipcRenderer.on('asynchronous-reply', (event, arg) => {
console.log(arg) // prints "pong"
})
function onTrackedVideoFrame(currentTime, duration) {
$("#current").text(currentTime);
$("#duration").text(duration);
if(duration-currentTime<=fadeOutTime)
{
ipcRenderer.send('request-video', true);
}
}
init();
});
</script>
</body>