-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
72 lines (64 loc) · 2.08 KB
/
script.js
File metadata and controls
72 lines (64 loc) · 2.08 KB
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
// Danh sách nhạc và video (file nằm cùng thư mục với HTML)
const musicListData = [
{ title: "trình", file: "trinh.mp3", cover: "trinh.jpeg" },
{ title: "Nơi này có anh - Sơn Tùng MTP", file: "noinaicoanh.mp3", cover: "music2.jpg" }
];
const videoListData = [
{ title: "MV Em Của Ngày Hôm Qua", file: "emcuangayhomqua.mp4", thumb: "video.jpeg" },
{ title: "Spirited Away Trailer", file: "spiritedaway.mp4", thumb: "video2.jpg" }
];
// --- CHUYỂN TAB ---
const musicTab = document.getElementById("musicTab");
const videoTab = document.getElementById("videoTab");
const musicSection = document.getElementById("musicSection");
const videoSection = document.getElementById("videoSection");
musicTab.onclick = () => {
musicTab.classList.add("active");
videoTab.classList.remove("active");
musicSection.classList.add("active");
videoSection.classList.remove("active");
};
videoTab.onclick = () => {
videoTab.classList.add("active");
musicTab.classList.remove("active");
videoSection.classList.add("active");
musicSection.classList.remove("active");
};
// --- NHẠC ---
const musicList = document.getElementById("musicList");
const audioPlayer = document.getElementById("audioPlayer");
musicListData.forEach(song => {
const item = document.createElement("div");
item.className = "music-item";
item.innerHTML = `
<img src="${song.cover}" alt="cover">
<div>
<strong>${song.title}</strong>
<p>${song.file}</p>
</div>
`;
item.onclick = () => {
audioPlayer.src = song.file;
audioPlayer.play();
};
musicList.appendChild(item);
});
// --- VIDEO ---
const videoList = document.getElementById("videoList");
const videoPlayer = document.getElementById("videoPlayer");
videoListData.forEach(vid => {
const item = document.createElement("div");
item.className = "video-item";
item.innerHTML = `
<img src="${vid.thumb}" alt="thumb">
<div>
<strong>${vid.title}</strong>
<p>${vid.file}</p>
</div>
`;
item.onclick = () => {
videoPlayer.src = vid.file;
videoPlayer.play();
};
videoList.appendChild(item);
});