forked from QAZIMAAZARSHAD/Movie-Streaming-Website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwatch-movie.html
201 lines (179 loc) · 9.38 KB
/
watch-movie.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title id="title-name-page"></title>
<link rel="shortcut icon" href="./Design/Netflix_icon.svg.png" type="image/x-icon">
<!-- Font -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Ubuntu&display=swap" rel="stylesheet">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<link href="./static/style.css" rel="stylesheet" type="text/css" />
<link href="./static/premium.css" rel="stylesheet" type="text/css" />
<!-- fontawesome 6.0.0 -->
<link href="./fontawesome-free-6.4.0-web/css/all.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<link rel="stylesheet" href="static/bootstrap.min.css">
<link rel="stylesheet" href="static/style-min.css">
<link rel="stylesheet" href="cards.css">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light layout_navbar__1COmD" id="header-nav">
<div class="container-fluid">
<a class="navbar-brand" href="index.html"><img class="logo" src="./Design/LogoWebRedBlack-02.png" alt="" width="30"
height="24"></a>
<button id="nav" class="navbar-toggler" id="nav" style="background-color:#8b0000" type="button" data-bs-toggle="collapse"
data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon" style="background-color:dark-grey;"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav me-auto mb-2 mb-lg-0 font_1em">
<li class="nav-item">
<a class="nav-link " href="movies.html" onMouseOver="this.style.color='red'" onMouseOut="this.style.color='white'">Phim ngắn</a>
</li>
<li class="nav-item">
<a class="nav-link " href="web-series.html" onMouseOver="this.style.color='red'" onMouseOut="this.style.color='white'" >Phim dài tập</a>
</li>
<li class="nav-item">
<a class="nav-link" href="kids.html" onMouseOver="this.style.color='red'" onMouseOut="this.style.color='white'">Anime</a>
</li>
<li class="nav-item">
<a class="nav-link" href="tv.html" onMouseOver="this.style.color='red'" onMouseOut="this.style.color='white'">TV</a>
</li>
<li class="nav-item">
<a class="nav-link" href="premium.html" onMouseOver="this.style.color='red'" onMouseOut="this.style.color='white'">Gói vip</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contactus.html" onMouseOver="this.style.color='red'" onMouseOut="this.style.color='white'">Liên hệ</a>
</li>
<li>
<!-- Genre dropdown starts-->
<div>
<div class="dropdown" style="position: relative; disPlay: inline-block; padding-top: 5px; padding-left: 15px;">
<button class="btn text-white" type="button" id="dropdownMenuButton" style="font-size:16px;margin-bottom: 6px;">
Thể loại <i class="fa-solid fa-chevron-down"></i>
</button>
<div class="dropdown-content" style="color: white;">
<a href="action.html">Hành động</a>
<a href="war.html">Chiến tranh</a>
<a href="drama.html">Drama</a>
<a href="suspense.html">Giật gân</a>
<a href="romance.html">Tình cảm</a>
<a href="anime.html">Hoạt hình</a>
<a href="horror.html">Kinh dị</a>
<a href="documentary.html">Lịch sử</a>
<a href="fantasy.html">Khoa học viễn tưởng</a>
<a href="comedy.html">Phim tâm lý</a>
</div>
</div>
</div>
<!-- Genre dropdown ends-->
</li>
<div style="position: relative; display: inline-block; padding-top: 5px; padding-left: 15px;" name="Account">
<script>
const divElement = document.querySelector('div[name="Account"]');
const ulElement = document.createElement('ul');
ulElement.style.display = 'flex';
ulElement.style.listStyle = 'none';
ulElement.innerHTML = renderLoginButton();
divElement.appendChild(ulElement);
function login(){
window.location.replace("login.html");
}
function logout() {
const apiUrl = 'http://localhost:8080/API/auth/signout';
fetch(apiUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' }
})
.then(response => {
if (response.ok) {
localStorage.removeItem('username');
window.location.reload(true);
} else {
console.error('Error:', response.statusText);
}
})
.catch(error => {
console.error('Error:', error);
});
}
function renderLoginButton() {
const username = localStorage.getItem('username');
if (username != null) {
return `
<li>
<button type="button" class="btn font-mulish btn-light" onclick="logout()">Đăng xuất</button>
</li>
<li style="margin-left: 8px;">
<button type="text" class="btn font-mulish btn-light" >Chào ${username}</button>
</li>
`;
} else {
return `
<li>
<button type="button" class="btn font-mulish btn-light" onclick="login()">Đăng nhập</button>
</li>
`;
}
}
</script>
</div>
</ul>
<form id="searchForm" class="d-flex" style=" justify-content: center;">
<input class="form-control me-2" type="text" id="searchText" placeholder="Tìm kiếm" aria-label="Search">
<button class="btn btn-danger" type="submit" onclick="searchMovies()"><i class="fa-solid fa-magnifying-glass"></i></button>
</form>
<script>
function searchMovies() {
const searchText = document.getElementById('searchText').value;
const searchParams = new URLSearchParams();
searchParams.append('searchResults', searchText);
window.location.href = 'search.html?' + searchParams.toString();
}
</script>
</div>
</div>
</nav>
<div class="" id="name-movie" style="font-size: 4em; color: white; font-weight: 600; padding-top: 30px;text-align: center;">
</div >
<div style="position: relative;width: 640px; text-align: center;">
</div>
<div style="text-align: center;">
<video width="880" autoplay controls id="video-movie" name="media">
<source src="" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
</body>
</html>
<script>
// Gọi hàm displaySearchResults() khi view search.html được tải
displaySearchResults();
function displaySearchResults() {
const urlParams = new URLSearchParams(window.location.search);
const id = urlParams.get('id');
fetch(`http://localhost:8080/API/phims/chi-tiet/${id}`)
.then(response => response.json())
.then(data => {
const srcVideo = "http://localhost:8080/photos/videos/";
const movieListElement = document.getElementById('movies1');
const movieNameElement = document.getElementById('name-movie');
movieNameElement.textContent = data.tenphim;
const imgElement = document.getElementById('video-movie');
imgElement.src = srcVideo + data.idphim + "/" + data.linkphim;
videoElement.addEventListener('loadeddata', function() {
videoElement.play();
});
// Xóa tham số 'searchResults' sau khi hiển thị dữ liệu
urlParams.delete('searchResults');
const newQueryString = urlParams.toString();
const newUrl = window.location.pathname + (newQueryString ? '?' + newQueryString : '');
window.history.replaceState({}, '', newUrl);
});
}
</script>