Skip to content

Commit 3465231

Browse files
committed
alerts: improvements on replays
Added replay class (and classes in general for videos) - closing sogebot#420 Added video filters - closing sogebot#419 Get rid of 3rd party videojs library
1 parent 891950b commit 3465231

File tree

8 files changed

+107
-40
lines changed

8 files changed

+107
-40
lines changed

libs/overlays/alerts.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ function Alerts () {
1515
global.configuration.register('replayOffsetY', 'core.no-response', 'number', '-300')
1616
global.configuration.register('replaySize', 'core.no-response', 'number', '600')
1717
global.configuration.register('replayVolume', 'core.no-response', 'number', '0')
18+
global.configuration.register('replayFilter', 'core.no-response', 'string', 'none')
1819
global.configuration.register('replayLabel', 'core.no-response-bool', 'bool', true)
1920

2021
global.panel.socketListening(this, 'replay-video', this.replay)
@@ -29,7 +30,9 @@ Alerts.prototype.replay = function (self, socket, data) {
2930
'y-offset=' + global.configuration.getValue('replayOffsetY'),
3031
'size=' + global.configuration.getValue('replaySize'),
3132
'volume=' + global.configuration.getValue('replayVolume'),
32-
'label=' + global.configuration.getValue('replayLabel')
33+
'label=' + global.configuration.getValue('replayLabel'),
34+
'filter=' + global.configuration.getValue('replayFilter'),
35+
'class=replay'
3336
]
3437
self.overlay(self, null, replay.join(' '))
3538
}

locales/cs.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,15 @@
7676
"offsetY": "Vertikální posun",
7777
"size": "Velikost videa",
7878
"volume": "Hlasitost",
79-
"label": "Ukazát 'replay' popisek"
79+
"label": "Ukazát 'replay' popisek",
80+
"filter": {
81+
"title": "Filter replaye",
82+
"none": "- žádný -",
83+
"grayscale": "grayscale",
84+
"sepia": "sepia",
85+
"tint": "tint",
86+
"washed": "vybledlé barvy"
87+
}
8088
}
8189
}
8290
},

locales/en.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,15 @@
7676
"offsetY": "Vertical offset",
7777
"size": "Video size",
7878
"volume": "Volume",
79-
"label": "Show 'replay' label"
79+
"label": "Show 'replay' label",
80+
"filter": {
81+
"title": "Replay filter",
82+
"none": "- none -",
83+
"grayscale": "grayscale",
84+
"sepia": "sepia",
85+
"tint": "tint",
86+
"washed": "washed out colors"
87+
}
8088
}
8189
}
8290
},

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"twitch-emoticons": "^2.1.0",
3838
"twitter": "^1.7.1",
3939
"velocity-animate": "^1.5.0",
40-
"video.js": "^6.2.5",
4140
"winston": "^2.3.1",
4241
"youtube-search": "^1.0.10",
4342
"ytdl-core": "^0.17.0"

public/dist/video/instant_replay.mp4

503 KB
Binary file not shown.

public/overlays/alerts.html

Lines changed: 68 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#video-rel-pos { display: table-cell; position: relative; height: 100%; width: 100%; }
3636
#video-rel-pos > div { display: inline-block !important; }
3737
#video {
38-
display: inline-block; opacity: 0
38+
display: inline-block !important; opacity: 0;
3939
}
4040
#video_html5_api { width: 100% }
4141
#images div img {
@@ -52,20 +52,44 @@
5252
ul {
5353
list-style-type: none;
5454
}
55+
56+
/* filters */
57+
.grayscale {
58+
-webkit-filter: grayscale(1);
59+
filter: grayscale(1);
60+
}
61+
.sepia {
62+
-webkit-filter: sepia(1);
63+
filter: sepia(1);
64+
}
65+
.tint {
66+
-webkit-filter: sepia(1) hue-rotate(200deg);
67+
filter: sepia(1) hue-rotate(200deg);
68+
}
69+
.washed {
70+
-webkit-filter: contrast(1.4) saturate(1.8) sepia(.6);
71+
filter: contrast(1.4) saturate(1.8) sepia(.6);
72+
}
73+
74+
5575
</style>
5676
</head>
5777
<body>
5878
<div id="images"></div>
5979
<div id="video-pos">
6080
<div id="video-rel-pos">
61-
<video id="video"></video>
81+
<video id="video">
82+
<source src="" type="video/mp4" />
83+
</video>
84+
<div id="replay-label" style="vertical-align: top; opacity:0; text-shadow: 0px 0px 2px black; position: absolute; font-family: 'Roboto Condensed', sans; color: red; font-weight: bold; text-transform: uppercase; margin-top: 5px; margin-left: -90px; width: 100%; text-align: left;"><i class="fa fa-circle" style="position:relative; top: -3px;" aria-hidden="true"></i>
85+
<span style="font-size:20px">REPLAY</span>
86+
</div>
6287
</div>
6388
</div>
6489

6590
<script src="/dist/jquery/js/jquery.min.js"></script>
6691
<script src="/dist/lodash/js/lodash.min.js"></script>
6792
<script src="/dist/velocity-animate/js/velocity.min.js"></script>
68-
<script src="/dist/video.js/js/video.js"></script>
6993

7094
<script>
7195
var socket = io({query: "token="+token});
@@ -245,6 +269,7 @@
245269
}
246270
video.volume = _.isNil(video.volume) ? 1 : parseInt(video.volume, 10) / 100
247271
video.delay = _.isNil(video.delay) ? 0 : parseInt(video.delay, 10)
272+
video.class = _.isNil(video.class) ? 'video' : video.class
248273

249274
let style = ''
250275
switch (video.position) {
@@ -286,43 +311,54 @@
286311
style += ';top:' + video['y-offset'] + 'px'
287312
}
288313

289-
var vjs = videojs('video', {
290-
controls: false,
291-
autoplay: false,
292-
preload: 'auto'
293-
})
314+
$('video source').attr('src', video.url)
315+
$('video')[0].load()
294316

295-
if (!_.isNil(video.size)) vjs.width(video.size)
317+
function checkLoad() {
318+
if ($('video')[0].readyState === 4) {
319+
$('video').prop("volume", video.volume)
320+
$('video').attr("width", video.size)
296321

297-
vjs.src(video.url)
298-
vjs.ready(function() {
299-
$('#replay-label').remove()
300-
if (video.label === 'true') {
301-
var label = $('<div id="replay-label" style="opacity:0; text-shadow: 0px 0px 2px black; position: relative; top:30px; left:-20px; font-family: \'Roboto Condensed\', sans; color: red; font-weight: bold; text-transform: uppercase; float:right"><i class="fa fa-circle" style="position:relative; top: -3px; aria-hidden="true"></i> <span style="font-size:20px">REPLAY</span></div>')
302-
label.velocity("fadeIn", { loop: true, duration: 1000 });
303-
$('#video').prepend(label)
304-
}
322+
if (!_.isNil(video.filter)) {
323+
$('video').addClass(video.filter)
324+
}
305325

306-
vjs.volume(video.volume)
326+
$('video').addClass(video.class)
307327

308-
$('#video-rel-pos').attr('style', style)
328+
if (video.label === 'true') {
329+
$('#replay-label').velocity("fadeIn", { loop: true, duration: 1000 });
330+
} else {
331+
$('#replay-label').css('opacity', 0)
332+
}
309333

310-
if (video.delay === 0) {
311-
vjs.play()
312-
$('#video').velocity("fadeIn", { duration: video.duration })
313-
} else {
314-
setTimeout(function () {
315-
vjs.play()
334+
$('#video-rel-pos').attr('style', style)
335+
336+
if (video.delay === 0) {
337+
$('video').trigger('play')
316338
$('#video').velocity("fadeIn", { duration: video.duration })
317-
}, video.delay)
339+
} else {
340+
setTimeout(function () {
341+
$('video').trigger('play')
342+
$('#video').velocity("fadeIn", { duration: video.duration })
343+
}, video.delay)
344+
}
345+
$("#video").bind("ended", function() {
346+
$("#replay-label").velocity("stop");
347+
$('#replay-label').velocity("fadeOut", { duration: video.duration });
348+
$('#video').velocity("fadeOut", { duration: video.duration, complete: function(e) {
349+
alertsQueue[id].finished++
350+
$('video').removeClass(video.class)
351+
if (!_.isNil(video.filter)) {
352+
$('video').removeClass(video.filter)
353+
}
354+
}})
355+
});
356+
} else {
357+
setTimeout(checkLoad, 100);
318358
}
319-
})
359+
}
320360

321-
vjs.on('ended', function() {
322-
$('#video').velocity("fadeOut", { duration: video.duration, complete: function(e) {
323-
alertsQueue[id].finished++
324-
}})
325-
})
361+
checkLoad()
326362
}
327363

328364
</script>

public/pages/overlays.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@
8080
</select>
8181
</td>
8282
</tr>
83+
<tr>
84+
<td><strong data-lang="page-settings.overlays.replay.filter.title"></strong></td>
85+
<td>
86+
<select id="overlay-replay-filter-select" class="form-control" onchange="saveReplayFil()">
87+
<option value="none" data-lang="page-settings.overlays.replay.filter.none"></option>
88+
<option value="grayscale" data-lang="page-settings.overlays.replay.filter.grayscale"></option>
89+
<option value="sepia" data-lang="page-settings.overlays.replay.filter.sepia"></option>
90+
<option value="tint" data-lang="page-settings.overlays.replay.filter.tint"></option>
91+
<option value="washed" data-lang="page-settings.overlays.replay.filter.washed"></option>
92+
</select>
93+
</td>
94+
</tr>
8395
<tr>
8496
<td><strong data-lang="page-settings.overlays.replay.offsetX"></strong></td>
8597
<td>
@@ -182,6 +194,7 @@
182194
$('#replayLabelToggle').data('init', true)
183195

184196
$('#overlay-replay-position-select option[value=' + data.replayPosition + ']').prop('selected', true)
197+
$('#overlay-replay-filter-select option[value=' + data.replayFilter + ']').prop('selected', true)
185198
})
186199

187200
socket.emit('overlay.images.get')
@@ -224,4 +237,8 @@
224237
socket.emit('saveConfiguration', {'replayPosition': $('#overlay-replay-position-select').val()})
225238
}
226239

240+
function saveReplayFil () {
241+
socket.emit('saveConfiguration', {'replayFilter': $('#overlay-replay-filter-select').val()})
242+
}
243+
227244
</script>

tools/copy-dist-files.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ var dist = {
3737
'velocity.min.js',
3838
'velocity.ui.min.js'
3939
]
40-
},
41-
'video.js': {
42-
'js': 'dist/video.js',
43-
'css': 'dist/video-js.css'
4440
}
4541
}
4642

0 commit comments

Comments
 (0)