-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
64 lines (54 loc) · 1.6 KB
/
index.js
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
import Webamp from "webamp";
const app = document.getElementById("app");
const button = document.getElementById("abrir_winamp");
const webamp = new Webamp({
initialTracks: [
{
metaData: {
title: "stream de audio de mi laptop",
artist: "schwifty",
},
url: "https://ricardotun.mx/now_playing",
duration: 0,
},
{
metaData: {
title: "Rock_Rock folder radio stream",
artist: "Mudo",
},
url: "https://ricardotun.mx/mudo/rock_rock",
duration: 0,
},
]
});
// Set the title to the currently playing track
webamp.onTrackDidChange((trackInfo) => {
let titleText = 'ricardotun.mx';
try {
let artist, title;
if (trackInfo && trackInfo.metaData) {
artist = trackInfo.metaData.artist || 'Unknown Artist';
title = trackInfo.metaData.title || 'Unknown Title';
titleText = `ricardotun.mx > now playing: ${title} by ${artist}`;
} else {
console.warn('No track information available or track metadata missing');
}
document.title = titleText;
} catch (error) {
console.error('Error updating document title:', error);
document.title = titleText;
}
});
webamp.onClose(() => {
function handleClick() {
webamp.reopen();
button.removeEventListener("click", handleClick);
}
button.addEventListener("click", handleClick);
});
function openWinamp() {
webamp.renderWhenReady(app);
button.removeEventListener("click", openWinamp)
}
button.addEventListener("click", openWinamp)
document.getElementById("copyright_year").appendChild(document.createTextNode(new Date().getFullYear()))