Spaces:
Running
Running
Add file
Browse files- gi_jukebox.html +237 -236
gi_jukebox.html
CHANGED
@@ -1,237 +1,238 @@
|
|
1 |
-
<!DOCTYPE html>
|
2 |
-
<html lang='en'>
|
3 |
-
<head>
|
4 |
-
<title>N/A</title>
|
5 |
-
<meta charset='utf-8'>
|
6 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.00">
|
7 |
-
<meta name="robots" content="noindex,nofollow,noarchive">
|
8 |
-
<script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
|
9 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/howler/2.2.3/howler.min.js" integrity="sha512-6+YN/9o9BWrk6wSfGxQGpt3EUK6XeHi6yeHV+TYD2GR0Sj/cggRpXr1BrAQf0as6XslxomMUxXp2vIl+fv0QRA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
10 |
-
<script src="https://cdn.plyr.io/3.7.3/plyr.js"></script>
|
11 |
-
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest/dist/hls.min.js"></script>
|
12 |
-
<link rel="stylesheet" href="https://cdn.plyr.io/3.7.3/plyr.css" />
|
13 |
-
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,[email protected],100..700,0..1,-50..200" />
|
14 |
-
<link href="https://cdn.jsdelivr.net/gh/daydreamer-json/SomeFontRepo@main/somefontrepo.css" rel="stylesheet" type="text/css" media="all">
|
15 |
-
<style>
|
16 |
-
html, body {
|
17 |
-
color: #fff;
|
18 |
-
background: #000;
|
19 |
-
margin: 0;
|
20 |
-
padding: 0;
|
21 |
-
line-height: 1;
|
22 |
-
width: 100vw;
|
23 |
-
height: 100vh;
|
24 |
-
font-family: 'SDK_JP_Web', system-ui;
|
25 |
-
}
|
26 |
-
#h2string1 {
|
27 |
-
margin: 0;
|
28 |
-
padding: 0;
|
29 |
-
line-height: 1;
|
30 |
-
}
|
31 |
-
#main {
|
32 |
-
position: absolute;
|
33 |
-
top: 50%;
|
34 |
-
left: 50%;
|
35 |
-
transform: translate(-50%, -50%);
|
36 |
-
text-align: center;
|
37 |
-
margin: 0;
|
38 |
-
padding: 0;
|
39 |
-
white-space: normal;
|
40 |
-
letter-spacing: -0.02em;
|
41 |
-
text-shadow: 0 0 30px #cccccc;
|
42 |
-
z-index: 100;
|
43 |
-
}
|
44 |
-
#cover_bg_container {
|
45 |
-
width: 100vw;
|
46 |
-
height: 100vh;
|
47 |
-
overflow: hidden;
|
48 |
-
}
|
49 |
-
#cover_bg {
|
50 |
-
z-index: 95;
|
51 |
-
width: 100vw;
|
52 |
-
height: 100vh;
|
53 |
-
opacity: 0.3;
|
54 |
-
object-fit: cover;
|
55 |
-
object-position: 50% 50%;
|
56 |
-
}
|
57 |
-
.do-not-select {
|
58 |
-
user-select: none;
|
59 |
-
}
|
60 |
-
.do-not-bold {
|
61 |
-
font-weight: normal;
|
62 |
-
}
|
63 |
-
</style>
|
64 |
-
</head>
|
65 |
-
<body>
|
66 |
-
<div id='cover_bg_container' class='do-not-select'>
|
67 |
-
<img id='cover_bg' src='' style='display: none;' class='do-not-select'>
|
68 |
-
</div>
|
69 |
-
<div id='main'>
|
70 |
-
<h2 id='h2string1' class='do-not-select do-not-bold'> </h1>
|
71 |
-
<h1 id='h1string1' class='do-not-select do-not-bold'> </h1>
|
72 |
-
<div id='trackInfo' class='do-not-select'>
|
73 |
-
<h3 id='trackInfo_trackName' class='do-not-bold' style='display: none;'> </h3>
|
74 |
-
<h4 id='trackInfo_albumName' class='do-not-bold' style='display: none;'> </h4>
|
75 |
-
<h4 id='trackInfo_artistName' class='do-not-bold' style='display: none;'> </h4>
|
76 |
-
<p id='trackInfo_copyright' style='display: none;'> </p>
|
77 |
-
</div>
|
78 |
-
</div>
|
79 |
-
<script>
|
80 |
-
let BASE_SETTINGS = {
|
81 |
-
base64var: {
|
82 |
-
pageTitle: 'R2Vuc2hpbiBJbXBhY3QgTXVzaWMgSnVrZWJveA==',
|
83 |
-
h2string1: 'R2Vuc2hpbiBJbXBhY3QgTXVzaWMgSnVrZWJveA=='
|
84 |
-
},
|
85 |
-
audioRootURL: 'https://raw.githubusercontent.com/daydreamer-json/discography_cdn_005/main/mhy/genshin',
|
86 |
-
playStartButtonText_init_pc: 'CLICK TO PLAY',
|
87 |
-
playStartButtonText_init_mobile: 'TAP TO PLAY',
|
88 |
-
playStartButtonText_loading: 'LOADING ...',
|
89 |
-
playStartButtonText_playing: 'NOW PLAYING',
|
90 |
-
trackInfoLabel_loading: 'Loading ...',
|
91 |
-
forceCompressedFormat: true
|
92 |
-
};
|
93 |
-
function detectMobileDevice() {
|
94 |
-
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
|
95 |
-
return 'mobile'
|
96 |
-
} else {
|
97 |
-
return 'pc'
|
98 |
-
}
|
99 |
-
}
|
100 |
-
function display_deobfuscate() {
|
101 |
-
document.title = atob(BASE_SETTINGS.base64var.pageTitle);
|
102 |
-
document.getElementById('h2string1').textContent = atob(BASE_SETTINGS.base64var.h2string1);
|
103 |
-
}
|
104 |
-
function randomTrackSelector(db) {
|
105 |
-
let random32bitArray = new Uint32Array(3);
|
106 |
-
window.crypto.getRandomValues(random32bitArray);
|
107 |
-
let randomizedAlbumIndex = random32bitArray[0] % db.list.length;
|
108 |
-
let randomizedDiscIndex = random32bitArray[1] % db.list[randomizedAlbumIndex].discs.length;
|
109 |
-
let randomizedTrackIndex = random32bitArray[2] % db.list[randomizedAlbumIndex].discs[randomizedDiscIndex].tracks.length;
|
110 |
-
return {
|
111 |
-
albumIndex: randomizedAlbumIndex,
|
112 |
-
discIndex: randomizedDiscIndex,
|
113 |
-
trackIndex: randomizedTrackIndex
|
114 |
-
};
|
115 |
-
}
|
116 |
-
function playAudioURLBuilder(db, randomTrackSelectorOutput) {
|
117 |
-
let deviceType = detectMobileDevice();
|
118 |
-
/*
|
119 |
-
let bpsArray = new Array();
|
120 |
-
for (let i = 0; i < db.list[randomTrackSelectorOutput.albumIndex].availableFmts.length; i++) {
|
121 |
-
bpsArray.push(db.list[randomTrackSelectorOutput.albumIndex].availableFmts[i].bps);
|
122 |
-
};
|
123 |
-
bpsArray.sort((a, b) => b - a);
|
124 |
-
*/
|
125 |
-
let formatPath = '';
|
126 |
-
let formatExt = '';
|
127 |
-
if (BASE_SETTINGS.forceCompressedFormat) {
|
128 |
-
formatPath = db.list[randomTrackSelectorOutput.albumIndex].availableFmts[db.list[randomTrackSelectorOutput.albumIndex].availableFmts.length - 1].path;
|
129 |
-
formatExt = db.list[randomTrackSelectorOutput.albumIndex].availableFmts[db.list[randomTrackSelectorOutput.albumIndex].availableFmts.length - 1].ext;
|
130 |
-
} else if (deviceType == 'pc') {
|
131 |
-
formatPath = db.list[randomTrackSelectorOutput.albumIndex].availableFmts[0].path;
|
132 |
-
formatExt = db.list[randomTrackSelectorOutput.albumIndex].availableFmts[0].ext;
|
133 |
-
} else if (deviceType == 'mobile') {
|
134 |
-
formatPath = db.list[randomTrackSelectorOutput.albumIndex].availableFmts[db.list[randomTrackSelectorOutput.albumIndex].availableFmts.length - 1].path;
|
135 |
-
formatExt = db.list[randomTrackSelectorOutput.albumIndex].availableFmts[db.list[randomTrackSelectorOutput.albumIndex].availableFmts.length - 1].ext;
|
136 |
-
}
|
137 |
-
let trackTotal = 0;
|
138 |
-
let trackCountArray = new Array();
|
139 |
-
for (let i = 0; i < db.list[randomTrackSelectorOutput.albumIndex].discs.length; i++) {
|
140 |
-
trackTotal += db.list[randomTrackSelectorOutput.albumIndex].discs[i].tracks.length;
|
141 |
-
trackCountArray.push(db.list[randomTrackSelectorOutput.albumIndex].discs[i].tracks.length);
|
142 |
-
};
|
143 |
-
let selectedTrackNum = 0;
|
144 |
-
if (randomTrackSelectorOutput.discIndex == 0) {
|
145 |
-
selectedTrackNum = randomTrackSelectorOutput.trackIndex + 1;
|
146 |
-
} else {
|
147 |
-
let E7BF25ECDBAAF938 = 0;
|
148 |
-
for (let i = 0; i < randomTrackSelectorOutput.discIndex; i++) {
|
149 |
-
E7BF25ECDBAAF938 += trackCountArray[i];
|
150 |
-
}
|
151 |
-
selectedTrackNum = E7BF25ECDBAAF938 + randomTrackSelectorOutput.trackIndex + 1;
|
152 |
-
}
|
153 |
-
let selectedTrackNumStr = '';
|
154 |
-
if (trackTotal >= 100) {
|
155 |
-
selectedTrackNumStr = selectedTrackNum.toString().padStart(3, '0');
|
156 |
-
} else if (trackTotal < 100) {
|
157 |
-
selectedTrackNumStr = selectedTrackNum.toString().padStart(2, '0');
|
158 |
-
}
|
159 |
-
let filename = encodeURIComponent(db.list[randomTrackSelectorOutput.albumIndex].discs[randomTrackSelectorOutput.discIndex].tracks[randomTrackSelectorOutput.trackIndex].trackName['en-US'].replace(/'/g, '_'));
|
160 |
-
let buildedURL = `${BASE_SETTINGS.audioRootURL}/${db.list[randomTrackSelectorOutput.albumIndex].rootPath}/${formatPath}/${selectedTrackNumStr}_${filename}.${formatExt}`;
|
161 |
-
return buildedURL;
|
162 |
-
}
|
163 |
-
function playAudio() {
|
164 |
-
document.getElementById('h1string1').removeEventListener('click', playAudio);
|
165 |
-
if (typeof audioPlayer !== 'undefined') {
|
166 |
-
audioPlayer.unload();
|
167 |
-
};
|
168 |
-
fetch(`${BASE_SETTINGS.audioRootURL}/db.json`)
|
169 |
-
.then(response => response.json())
|
170 |
-
.then(data => {
|
171 |
-
console.log('Database loaded successfully');
|
172 |
-
const FILE_DATABASE = data;
|
173 |
-
let deviceType = detectMobileDevice();
|
174 |
-
let randomTrackSelectorOutput = randomTrackSelector(FILE_DATABASE);
|
175 |
-
var audioPlayer = new Howl ({
|
176 |
-
src: [playAudioURLBuilder(FILE_DATABASE, randomTrackSelectorOutput)],
|
177 |
-
html5: true
|
178 |
-
});
|
179 |
-
window.audioPlayer = audioPlayer;
|
180 |
-
document.getElementById('h1string1').textContent = BASE_SETTINGS.playStartButtonText_loading;
|
181 |
-
document.getElementById('trackInfo_trackName').textContent = BASE_SETTINGS.trackInfoLabel_loading;
|
182 |
-
document.getElementById('trackInfo_albumName').textContent = BASE_SETTINGS.trackInfoLabel_loading;
|
183 |
-
document.getElementById('trackInfo_artistName').textContent = BASE_SETTINGS.trackInfoLabel_loading;
|
184 |
-
document.getElementById('trackInfo_copyright').textContent = BASE_SETTINGS.trackInfoLabel_loading;
|
185 |
-
audioPlayer.on('loaderror', function(){
|
186 |
-
console.error('Audio "loaderror" has occured. Retrying ...');
|
187 |
-
playAudio();
|
188 |
-
});
|
189 |
-
audioPlayer.on('playerror', function(){
|
190 |
-
console.error('Audio "playerror" has occured. Retrying ...');
|
191 |
-
playAudio();
|
192 |
-
});
|
193 |
-
audioPlayer.on('load', function(){
|
194 |
-
audioPlayer.play();
|
195 |
-
document.getElementById('h1string1').addEventListener('click', playAudio);
|
196 |
-
document.getElementById('h1string1').textContent = BASE_SETTINGS.playStartButtonText_playing;
|
197 |
-
console.log(`Now playing "${FILE_DATABASE.list[randomTrackSelectorOutput.albumIndex].discs[randomTrackSelectorOutput.discIndex].tracks[randomTrackSelectorOutput.trackIndex].trackName['en-US']}"`);
|
198 |
-
console.log(`URL: ${audioPlayer._src}`);
|
199 |
-
document.getElementById('trackInfo_trackName').textContent = FILE_DATABASE.list[randomTrackSelectorOutput.albumIndex].discs[randomTrackSelectorOutput.discIndex].tracks[randomTrackSelectorOutput.trackIndex].trackName['en-US'];
|
200 |
-
document.getElementById('trackInfo_albumName').textContent = FILE_DATABASE.list[randomTrackSelectorOutput.albumIndex].albumTitle;
|
201 |
-
document.getElementById('trackInfo_artistName').textContent = FILE_DATABASE.list[randomTrackSelectorOutput.albumIndex].albumArtist;
|
202 |
-
document.getElementById('trackInfo_copyright').textContent = FILE_DATABASE.list[randomTrackSelectorOutput.albumIndex].copyright;
|
203 |
-
document.getElementById('cover_bg').src = FILE_DATABASE.list[randomTrackSelectorOutput.albumIndex].
|
204 |
-
|
205 |
-
|
206 |
-
document.getElementById('
|
207 |
-
document.getElementById('
|
208 |
-
document.getElementById('
|
209 |
-
document.getElementById('
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
</
|
|
|
237 |
</html>
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang='en'>
|
3 |
+
<head>
|
4 |
+
<title>N/A</title>
|
5 |
+
<meta charset='utf-8'>
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.00">
|
7 |
+
<meta name="robots" content="noindex,nofollow,noarchive">
|
8 |
+
<script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
|
9 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/howler/2.2.3/howler.min.js" integrity="sha512-6+YN/9o9BWrk6wSfGxQGpt3EUK6XeHi6yeHV+TYD2GR0Sj/cggRpXr1BrAQf0as6XslxomMUxXp2vIl+fv0QRA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
10 |
+
<script src="https://cdn.plyr.io/3.7.3/plyr.js"></script>
|
11 |
+
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest/dist/hls.min.js"></script>
|
12 |
+
<link rel="stylesheet" href="https://cdn.plyr.io/3.7.3/plyr.css" />
|
13 |
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,[email protected],100..700,0..1,-50..200" />
|
14 |
+
<link href="https://cdn.jsdelivr.net/gh/daydreamer-json/SomeFontRepo@main/somefontrepo.css" rel="stylesheet" type="text/css" media="all">
|
15 |
+
<style>
|
16 |
+
html, body {
|
17 |
+
color: #fff;
|
18 |
+
background: #000;
|
19 |
+
margin: 0;
|
20 |
+
padding: 0;
|
21 |
+
line-height: 1;
|
22 |
+
width: 100vw;
|
23 |
+
height: 100vh;
|
24 |
+
font-family: 'SDK_JP_Web', system-ui;
|
25 |
+
}
|
26 |
+
#h2string1 {
|
27 |
+
margin: 0;
|
28 |
+
padding: 0;
|
29 |
+
line-height: 1;
|
30 |
+
}
|
31 |
+
#main {
|
32 |
+
position: absolute;
|
33 |
+
top: 50%;
|
34 |
+
left: 50%;
|
35 |
+
transform: translate(-50%, -50%);
|
36 |
+
text-align: center;
|
37 |
+
margin: 0;
|
38 |
+
padding: 0;
|
39 |
+
white-space: normal;
|
40 |
+
letter-spacing: -0.02em;
|
41 |
+
text-shadow: 0 0 30px #cccccc;
|
42 |
+
z-index: 100;
|
43 |
+
}
|
44 |
+
#cover_bg_container {
|
45 |
+
width: 100vw;
|
46 |
+
height: 100vh;
|
47 |
+
overflow: hidden;
|
48 |
+
}
|
49 |
+
#cover_bg {
|
50 |
+
z-index: 95;
|
51 |
+
width: 100vw;
|
52 |
+
height: 100vh;
|
53 |
+
opacity: 0.3;
|
54 |
+
object-fit: cover;
|
55 |
+
object-position: 50% 50%;
|
56 |
+
}
|
57 |
+
.do-not-select {
|
58 |
+
user-select: none;
|
59 |
+
}
|
60 |
+
.do-not-bold {
|
61 |
+
font-weight: normal;
|
62 |
+
}
|
63 |
+
</style>
|
64 |
+
</head>
|
65 |
+
<body>
|
66 |
+
<div id='cover_bg_container' class='do-not-select'>
|
67 |
+
<img id='cover_bg' src='' style='display: none;' class='do-not-select'>
|
68 |
+
</div>
|
69 |
+
<div id='main'>
|
70 |
+
<h2 id='h2string1' class='do-not-select do-not-bold'> </h1>
|
71 |
+
<h1 id='h1string1' class='do-not-select do-not-bold'> </h1>
|
72 |
+
<div id='trackInfo' class='do-not-select'>
|
73 |
+
<h3 id='trackInfo_trackName' class='do-not-bold' style='display: none;'> </h3>
|
74 |
+
<h4 id='trackInfo_albumName' class='do-not-bold' style='display: none;'> </h4>
|
75 |
+
<h4 id='trackInfo_artistName' class='do-not-bold' style='display: none;'> </h4>
|
76 |
+
<p id='trackInfo_copyright' style='display: none;'> </p>
|
77 |
+
</div>
|
78 |
+
</div>
|
79 |
+
<script>
|
80 |
+
let BASE_SETTINGS = {
|
81 |
+
base64var: {
|
82 |
+
pageTitle: 'R2Vuc2hpbiBJbXBhY3QgTXVzaWMgSnVrZWJveA==',
|
83 |
+
h2string1: 'R2Vuc2hpbiBJbXBhY3QgTXVzaWMgSnVrZWJveA=='
|
84 |
+
},
|
85 |
+
audioRootURL: 'https://raw.githubusercontent.com/daydreamer-json/discography_cdn_005/main/mhy/genshin',
|
86 |
+
playStartButtonText_init_pc: 'CLICK TO PLAY',
|
87 |
+
playStartButtonText_init_mobile: 'TAP TO PLAY',
|
88 |
+
playStartButtonText_loading: 'LOADING ...',
|
89 |
+
playStartButtonText_playing: 'NOW PLAYING',
|
90 |
+
trackInfoLabel_loading: 'Loading ...',
|
91 |
+
forceCompressedFormat: true
|
92 |
+
};
|
93 |
+
function detectMobileDevice() {
|
94 |
+
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
|
95 |
+
return 'mobile'
|
96 |
+
} else {
|
97 |
+
return 'pc'
|
98 |
+
}
|
99 |
+
}
|
100 |
+
function display_deobfuscate() {
|
101 |
+
document.title = atob(BASE_SETTINGS.base64var.pageTitle);
|
102 |
+
document.getElementById('h2string1').textContent = atob(BASE_SETTINGS.base64var.h2string1);
|
103 |
+
}
|
104 |
+
function randomTrackSelector(db) {
|
105 |
+
let random32bitArray = new Uint32Array(3);
|
106 |
+
window.crypto.getRandomValues(random32bitArray);
|
107 |
+
let randomizedAlbumIndex = random32bitArray[0] % db.list.length;
|
108 |
+
let randomizedDiscIndex = random32bitArray[1] % db.list[randomizedAlbumIndex].discs.length;
|
109 |
+
let randomizedTrackIndex = random32bitArray[2] % db.list[randomizedAlbumIndex].discs[randomizedDiscIndex].tracks.length;
|
110 |
+
return {
|
111 |
+
albumIndex: randomizedAlbumIndex,
|
112 |
+
discIndex: randomizedDiscIndex,
|
113 |
+
trackIndex: randomizedTrackIndex
|
114 |
+
};
|
115 |
+
}
|
116 |
+
function playAudioURLBuilder(db, randomTrackSelectorOutput) {
|
117 |
+
let deviceType = detectMobileDevice();
|
118 |
+
/*
|
119 |
+
let bpsArray = new Array();
|
120 |
+
for (let i = 0; i < db.list[randomTrackSelectorOutput.albumIndex].availableFmts.length; i++) {
|
121 |
+
bpsArray.push(db.list[randomTrackSelectorOutput.albumIndex].availableFmts[i].bps);
|
122 |
+
};
|
123 |
+
bpsArray.sort((a, b) => b - a);
|
124 |
+
*/
|
125 |
+
let formatPath = '';
|
126 |
+
let formatExt = '';
|
127 |
+
if (BASE_SETTINGS.forceCompressedFormat) {
|
128 |
+
formatPath = db.list[randomTrackSelectorOutput.albumIndex].availableFmts[db.list[randomTrackSelectorOutput.albumIndex].availableFmts.length - 1].path;
|
129 |
+
formatExt = db.list[randomTrackSelectorOutput.albumIndex].availableFmts[db.list[randomTrackSelectorOutput.albumIndex].availableFmts.length - 1].ext;
|
130 |
+
} else if (deviceType == 'pc') {
|
131 |
+
formatPath = db.list[randomTrackSelectorOutput.albumIndex].availableFmts[0].path;
|
132 |
+
formatExt = db.list[randomTrackSelectorOutput.albumIndex].availableFmts[0].ext;
|
133 |
+
} else if (deviceType == 'mobile') {
|
134 |
+
formatPath = db.list[randomTrackSelectorOutput.albumIndex].availableFmts[db.list[randomTrackSelectorOutput.albumIndex].availableFmts.length - 1].path;
|
135 |
+
formatExt = db.list[randomTrackSelectorOutput.albumIndex].availableFmts[db.list[randomTrackSelectorOutput.albumIndex].availableFmts.length - 1].ext;
|
136 |
+
}
|
137 |
+
let trackTotal = 0;
|
138 |
+
let trackCountArray = new Array();
|
139 |
+
for (let i = 0; i < db.list[randomTrackSelectorOutput.albumIndex].discs.length; i++) {
|
140 |
+
trackTotal += db.list[randomTrackSelectorOutput.albumIndex].discs[i].tracks.length;
|
141 |
+
trackCountArray.push(db.list[randomTrackSelectorOutput.albumIndex].discs[i].tracks.length);
|
142 |
+
};
|
143 |
+
let selectedTrackNum = 0;
|
144 |
+
if (randomTrackSelectorOutput.discIndex == 0) {
|
145 |
+
selectedTrackNum = randomTrackSelectorOutput.trackIndex + 1;
|
146 |
+
} else {
|
147 |
+
let E7BF25ECDBAAF938 = 0;
|
148 |
+
for (let i = 0; i < randomTrackSelectorOutput.discIndex; i++) {
|
149 |
+
E7BF25ECDBAAF938 += trackCountArray[i];
|
150 |
+
}
|
151 |
+
selectedTrackNum = E7BF25ECDBAAF938 + randomTrackSelectorOutput.trackIndex + 1;
|
152 |
+
}
|
153 |
+
let selectedTrackNumStr = '';
|
154 |
+
if (trackTotal >= 100) {
|
155 |
+
selectedTrackNumStr = selectedTrackNum.toString().padStart(3, '0');
|
156 |
+
} else if (trackTotal < 100) {
|
157 |
+
selectedTrackNumStr = selectedTrackNum.toString().padStart(2, '0');
|
158 |
+
}
|
159 |
+
let filename = encodeURIComponent(db.list[randomTrackSelectorOutput.albumIndex].discs[randomTrackSelectorOutput.discIndex].tracks[randomTrackSelectorOutput.trackIndex].trackName['en-US'].replace(/'/g, '_'));
|
160 |
+
let buildedURL = `${BASE_SETTINGS.audioRootURL}/${db.list[randomTrackSelectorOutput.albumIndex].rootPath}/${formatPath}/${selectedTrackNumStr}_${filename}.${formatExt}`;
|
161 |
+
return buildedURL;
|
162 |
+
}
|
163 |
+
function playAudio() {
|
164 |
+
document.getElementById('h1string1').removeEventListener('click', playAudio);
|
165 |
+
if (typeof audioPlayer !== 'undefined') {
|
166 |
+
audioPlayer.unload();
|
167 |
+
};
|
168 |
+
fetch(`${BASE_SETTINGS.audioRootURL}/db.json`)
|
169 |
+
.then(response => response.json())
|
170 |
+
.then(data => {
|
171 |
+
console.log('Database loaded successfully');
|
172 |
+
const FILE_DATABASE = data;
|
173 |
+
let deviceType = detectMobileDevice();
|
174 |
+
let randomTrackSelectorOutput = randomTrackSelector(FILE_DATABASE);
|
175 |
+
var audioPlayer = new Howl ({
|
176 |
+
src: [playAudioURLBuilder(FILE_DATABASE, randomTrackSelectorOutput)],
|
177 |
+
html5: true
|
178 |
+
});
|
179 |
+
window.audioPlayer = audioPlayer;
|
180 |
+
document.getElementById('h1string1').textContent = BASE_SETTINGS.playStartButtonText_loading;
|
181 |
+
document.getElementById('trackInfo_trackName').textContent = BASE_SETTINGS.trackInfoLabel_loading;
|
182 |
+
document.getElementById('trackInfo_albumName').textContent = BASE_SETTINGS.trackInfoLabel_loading;
|
183 |
+
document.getElementById('trackInfo_artistName').textContent = BASE_SETTINGS.trackInfoLabel_loading;
|
184 |
+
document.getElementById('trackInfo_copyright').textContent = BASE_SETTINGS.trackInfoLabel_loading;
|
185 |
+
audioPlayer.on('loaderror', function(){
|
186 |
+
console.error('Audio "loaderror" has occured. Retrying ...');
|
187 |
+
playAudio();
|
188 |
+
});
|
189 |
+
audioPlayer.on('playerror', function(){
|
190 |
+
console.error('Audio "playerror" has occured. Retrying ...');
|
191 |
+
playAudio();
|
192 |
+
});
|
193 |
+
audioPlayer.on('load', function(){
|
194 |
+
audioPlayer.play();
|
195 |
+
document.getElementById('h1string1').addEventListener('click', playAudio);
|
196 |
+
document.getElementById('h1string1').textContent = BASE_SETTINGS.playStartButtonText_playing;
|
197 |
+
console.log(`Now playing "${FILE_DATABASE.list[randomTrackSelectorOutput.albumIndex].discs[randomTrackSelectorOutput.discIndex].tracks[randomTrackSelectorOutput.trackIndex].trackName['en-US']}"`);
|
198 |
+
console.log(`URL: ${audioPlayer._src}`);
|
199 |
+
document.getElementById('trackInfo_trackName').textContent = FILE_DATABASE.list[randomTrackSelectorOutput.albumIndex].discs[randomTrackSelectorOutput.discIndex].tracks[randomTrackSelectorOutput.trackIndex].trackName['en-US'];
|
200 |
+
document.getElementById('trackInfo_albumName').textContent = FILE_DATABASE.list[randomTrackSelectorOutput.albumIndex].albumTitle;
|
201 |
+
document.getElementById('trackInfo_artistName').textContent = FILE_DATABASE.list[randomTrackSelectorOutput.albumIndex].albumArtist;
|
202 |
+
document.getElementById('trackInfo_copyright').textContent = FILE_DATABASE.list[randomTrackSelectorOutput.albumIndex].copyright;
|
203 |
+
document.getElementById('cover_bg').src = `${BASE_SETTINGS.audioRootURL}/${FILE_DATABASE.list[randomTrackSelectorOutput.albumIndex].rootPath}/cover.webp`;
|
204 |
+
|
205 |
+
if (document.getElementById('trackInfo_trackName').style.display == 'none' && document.getElementById('trackInfo_albumName').style.display == 'none' && document.getElementById('trackInfo_artistName').style.display == 'none' && document.getElementById('trackInfo_copyright').style.display == 'none' && document.getElementById('cover_bg').style.display == 'none') {
|
206 |
+
document.getElementById('trackInfo_trackName').style.display = 'block';
|
207 |
+
document.getElementById('trackInfo_albumName').style.display = 'block';
|
208 |
+
document.getElementById('trackInfo_artistName').style.display = 'block';
|
209 |
+
document.getElementById('trackInfo_copyright').style.display = 'block';
|
210 |
+
document.getElementById('cover_bg').style.display = 'block';
|
211 |
+
}
|
212 |
+
audioPlayer.on('end', playAudio);
|
213 |
+
});
|
214 |
+
})
|
215 |
+
.catch(error => {
|
216 |
+
console.error(error);
|
217 |
+
alert('Failed to load database file');
|
218 |
+
});
|
219 |
+
}
|
220 |
+
document.addEventListener('DOMContentLoaded', function() {
|
221 |
+
display_deobfuscate();
|
222 |
+
let deviceType = detectMobileDevice();
|
223 |
+
if (deviceType == 'pc') {
|
224 |
+
document.getElementById('h1string1').textContent = BASE_SETTINGS.playStartButtonText_init_pc;
|
225 |
+
} else if (deviceType == 'mobile') {
|
226 |
+
document.getElementById('h1string1').textContent = BASE_SETTINGS.playStartButtonText_init_mobile;
|
227 |
+
};
|
228 |
+
var audioPlayer = new Howl ({
|
229 |
+
src: ['https://archive.org/download/audio-silent-wavs-one-second-half-second-quarter-second/silent_quarter-second.mp3']
|
230 |
+
});
|
231 |
+
window.audioPlayer = audioPlayer;
|
232 |
+
});
|
233 |
+
window.onload = function () {
|
234 |
+
document.getElementById('h1string1').addEventListener('click', playAudio);
|
235 |
+
}
|
236 |
+
</script>
|
237 |
+
</body>
|
238 |
</html>
|