-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
executable file
·146 lines (132 loc) · 4.41 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>Drive/370</title>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" title="main" href="./css/drivey.css" />
<style>
.audio-controls {
position: fixed;
top: 10px;
left: 10px;
z-index: 1000;
}
.audio-button {
background: rgba(0, 0, 0, 0.5);
color: white;
border: 1px solid white;
padding: 5px 10px;
margin-right: 5px;
cursor: pointer;
font-family: Arial, sans-serif;
}
.audio-button:hover {
background: rgba(0, 0, 0, 0.7);
}
.version {
position: fixed;
bottom: 10px;
left: 10px;
color: rgba(255, 255, 255, 0.3);
font-family: Arial, sans-serif;
font-size: 12px;
z-index: 1000;
}
.current-song {
position: fixed;
top: 10px;
right: 10px;
color: rgba(255, 255, 255, 0.3);
font-family: Arial, sans-serif;
font-size: 12px;
z-index: 1000;
}
</style>
</head>
<body>
<div class="audio-controls">
<button id="muteButton" class="audio-button">Mute</button>
<button id="skipButton" class="audio-button">Skip</button>
</div>
<div class="version">v2.2</div>
<div id="currentSong" class="current-song"></div>
<script src="./lib/theme.js"></script>
<script type="module">
console.log("Starting music setup...");
const audioPlayer = new Audio();
let shuffledPlaylist = [];
let currentTrackIndex = 0;
let isMuted = false;
// Get button elements
const muteButton = document.getElementById('muteButton');
const skipButton = document.getElementById('skipButton');
// Mute button handler
muteButton.addEventListener('click', () => {
isMuted = !isMuted;
audioPlayer.muted = isMuted;
muteButton.textContent = isMuted ? 'Unmute' : 'Mute';
});
// Skip button handler
skipButton.addEventListener('click', () => {
currentTrackIndex++;
if (currentTrackIndex >= shuffledPlaylist.length) {
shuffledPlaylist.sort(() => Math.random() - 0.5);
currentTrackIndex = 0;
}
audioPlayer.src = shuffledPlaylist[currentTrackIndex];
audioPlayer.play();
updateSongDisplay(shuffledPlaylist[currentTrackIndex]);
});
// Define the list of known FLAC files
const flacFiles = [
'./Aloft_BGM.flac',
'./Cipher_BGM.flac',
'./Biosignature_BGM.flac',
'./Blackout_BGM.flac',
'./Cosmic_Solitude_BGM.flac',
'./Melancholy_BGM.flac',
'./Siberian.flac',
'./Triangular_BGM.flac',
'./Encounters_BGM.flac',
'./Nation.mp3',
'./Determination.mp3',
'./nocturnal.flac'
];
shuffledPlaylist = [...flacFiles].sort(() => Math.random() - 0.5);
console.log("Shuffled playlist:", shuffledPlaylist);
audioPlayer.addEventListener('ended', () => {
console.log("Track ended, playing next...");
currentTrackIndex++;
if (currentTrackIndex >= shuffledPlaylist.length) {
shuffledPlaylist.sort(() => Math.random() - 0.5);
currentTrackIndex = 0;
}
audioPlayer.src = shuffledPlaylist[currentTrackIndex];
audioPlayer.play();
updateSongDisplay(shuffledPlaylist[currentTrackIndex]);
});
// Start playing on first user interaction
const startMusic = () => {
console.log("Starting first track:", shuffledPlaylist[0]);
audioPlayer.src = shuffledPlaylist[0];
audioPlayer.play();
updateSongDisplay(shuffledPlaylist[0]);
// Remove the event listeners once music starts
document.removeEventListener('click', startMusic);
document.removeEventListener('keydown', startMusic);
};
document.addEventListener('click', startMusic);
document.addEventListener('keydown', startMusic);
// Original Drivey initialization
import Drivey from "./js/Drivey.js";
document.addEventListener("touchmove", (e) => e.preventDefault(), {
passive: false,
});
window.drivey = new Drivey();
function updateSongDisplay(filePath) {
const songName = filePath.split('/').pop().replace('.flac', '');
document.getElementById('currentSong').textContent = songName;
}
</script>
</body>
</html>