-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideos.html
155 lines (136 loc) · 6.6 KB
/
videos.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
<!DOCTYPE html>
<html>
<head>
<title>Michelle Su</title> <!-- Appear on tab -->
<!-- favicon (source: fontawesome; license: https://fontawesome.com/license) -->
<link rel="shortcut icon" type="image/x-icon" href="images/cat-solid.svg">
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
<!-- bootstrap/javascript/jquery for modal -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<!-- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> -->
<script src="script.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body style="background-color:rgb(202, 235, 235);">
<div class="main-nav-bar">
<a href="https://michellesu.github.io/cs185_portfolio/">Home</a>
<a href="images.html">Around The World</a>
<a class="active" href="videos.html">Videos</a>
<a href="projects.html">Projects</a>
</div>
<div class="video-body">
<!-- <p>
<b>Favorite study music</b>
</p> -->
<div class="video-container">
<div class="img-child">
<!-- <iframe width="400" height="270" src="https://www.youtube.com/embed/tuYuh0wRPGw" frameborder="10" allowfullscreen></iframe> -->
<video width="400" height="270" src="videos/vid1.mp4" type="video/mp4" controls>
<!-- <source src="videos/vid1.mp4" type="video/mp4"> -->
</video>
</div>
<div class="img-child">
<!-- <iframe width="400" height="270" src="https://www.youtube.com/embed/5qap5aO4i9A" frameborder="0" allowfullscreen></iframe> -->
<video width="400" height="270" src="videos/vid2.mp4" type="video/mp4" controls>
</video>
</div>
<div class="img-child">
<!-- <iframe width="400" height="270" src="https://www.youtube.com/embed/JPfE3JJkot0" frameborder="0" allowfullscreen></iframe> -->
<video width="400" height="270" src="videos/vid3.mp4" type="video/mp4" controls>
</video>
</div>
<div class="img-child">
<!-- <iframe width="420" height="310" src="https://www.youtube.com/embed/TQqVB3q23Ys"></iframe> -->
<video width="400" height="270" src="videos/vid4.mp4" type="video/mp4" controls>
</video>
</div>
</div>
</div>
<!-- back to top button, appears after user scroll for a bit -->
<button id="backToTopButton" onclick="scrollToTop()">Back to top</button>
<!-- video modal script -->
<script>
// Bootstrap modal script
// $(document).ready(function() { // prevent jquery from running before document is fully loaded
// console.log("hello world!!!!!!!!!!!!!!!!");
// $(".img-child").click(function(e) {
// // stop video on the page from playing because we want it to play in modal
// e.preventDefault();
// $('.videopreview').attr('src', $(this).find('video').attr('src'));
// var url = $(this).find('video').attr('src');
// console.log(url);
// console.log(url == "videos/vid4.mp4");
// // set size of different videos
// if(url == "videos/vid4.mp4") {
// $('.videopreview').attr('width', "100%");
// $('.videopreview').attr('height', "auto");
// console.log("in if statement");
// }
// else {
// $('.videopreview').attr('width', "auto");
// $('.videopreview').attr('height', "90%");
// }
// // make modal appear
// $("#myModal").modal();
// // autoplay video when modal pops up
// // $("#myModal").on('show.bs.modal', function(){
// // $(".videopreview")[0].play();
// // });
// });
// // stop modal video from playing when modal disappears
// $("#myModal").on('hide.bs.modal', function(){
// $(".videopreview").attr('src', '');
// });
// });
// insert modal div
var modal = document.createElement("div");
modal.id = "modal";
document.body.appendChild(modal);
// add event listener to videos
var videos = document.querySelectorAll("video");
// console.log(videos)
videos.forEach(item => {
item.addEventListener("click", e => {
// prevent video from playing when you click on them - want them to play in modal
e.preventDefault();
var vid = document.createElement('video');
vid.id = "videopreview";
vid.src = item.src;
vid.autoplay = "autoplay";
vid.controls = "controls";
// remove other videos from modal if they were previously clicked on/added
modal.innerHTML = "";
modal.appendChild(vid);
modal.className = "showmodal";
});
})
modal.addEventListener("click", e => {
if(e.target != e.currentTarget)
return;
modal.classList.remove("showmodal");
// stop modal video from playing in the background after exiting modal
var vid = document.getElementById("videopreview");
vid.src = "";
})
</script>
<!-- Bootstrap Modal -->
<!-- <div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog"> -->
<!-- Modal content-->
<!-- <div class="modal-content"> -->
<!-- <div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
</div> -->
<!-- <div class="modal-body">
<video src="" class="videopreview" controls autoplay="autoplay"></video> -->
<!-- <iframe src="" class="videopreview" width="100%" height="100%" allowfullscreen></iframe> -->
<!-- <div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src="" allowfullscreen allowautoplay></iframe>
</div> -->
<!-- </div>
</div>
</div>
</div> -->
</body>
</html>