-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvideo-grid.html
136 lines (120 loc) · 3.45 KB
/
video-grid.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
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<style>
html, body{
height: 100%;
overflow: hidden;
margin: 0px;
font-family: 'Helvetica', sans-serif;
}
.grid-vid-row{
height: 50%;
}
.grid-vid-item{
width: 50%;
height: 100%;
float: left;
}
/*
CSS filter property
https://www.w3schools.com/cssref/css3_pr_filter.asp
CSS filter demo
https://www.w3schools.com/cssref/playit.asp?filename=playcss_filter&preval=none
*/
.grid-vid{
width: 100%;
height: 100%;
filter: grayscale(100%);
transition: filter 2s;
}
.grid-vid:hover{
filter: grayscale(0%);
cursor: pointer;
}
@keyframes changeColor{
from{
filter: hue-rotate(0deg);
}
to{
filter: hue-rotate(360deg);
}
}
</style>
<body>
<div class="grid-vid-row">
<div class="grid-vid-item">
<video onclick="" class="grid-vid" autoplay loop muted>
<source src="assets/video/piano_jiwon.mp4" type="video/mp4">
</video>
</div>
<div class="grid-vid-item">
<video class="grid-vid" autoplay loop muted>
<source src="assets/video/piano_leon.mp4" type="video/mp4">
</video>
</div>
</div>
<div class="grid-vid-row">
<div class="grid-vid-item">
<video class="grid-vid" autoplay loop muted>
<source src="assets/video/guitar.mp4" type="video/mp4">
</video>
</div>
<div class="grid-vid-item">
<video class="grid-vid" autoplay loop muted>
<source src="assets/video/drum.mp4" type="video/mp4">
</video>
</div>
</div>
</body>
<script type="text/javascript">
//Audio / Video DOM references
//https://www.w3schools.com/tags/ref_av_dom.asp
var grid_videos = [];
var numPlaying = 0;
window.onload = function(){
console.log("loading window");
full_vid = document.getElementById('full-page');
options = document.getElementById('options');
grid_videos = document.getElementsByClassName('grid-vid');
for(var i = 0; i < grid_videos.length; i++){
// grid_videos[i].setAttribute("onmouseover", "unmuteVid("+ i + ")");
// grid_videos[i].setAttribute("onmouseout", "muteVid(" + i + ")");
grid_videos[i].setAttribute("onclick", "playVid(" + i + ")");
}
};
function unmuteVid(vidNum){
// console.log(vidNum);
grid_videos[vidNum].muted = false;
}
function muteVid(vidNum){
grid_videos[vidNum].muted = true;
}
function playVid(vidNum){
var video = grid_videos[vidNum];
video.muted = !video.muted;
if(video.muted){
video.style.filter = "grayscale(100%)";
numPlaying--;
}else{
video.style.filter = "grayscale(0%)";
numPlaying++;
}
console.log(numPlaying);
if(numPlaying == 4){
console.log("all playing!");
for(var i = 0; i < grid_videos.length; i++){
document.body.style.backgroundColor = "red";
grid_videos[i].style.animation = "changeColor 1s infinite";
}
}else{
for(var i = 0; i < grid_videos.length; i++){
document.body.style.backgroundColor = "white";
grid_videos[i].style.animation = null;
}
}
}
</script>
</html>