-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
41 lines (39 loc) · 1.21 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FPlayer.js demo</title>
</head>
<body>
<div id="app"></div>
<script type="module">
import FPlayer from "@/main";
import Music from "@/beans/Music";
FPlayer.init();
var fplayer = FPlayer.create("#app", {
mode: FPlayer.MODE_LIST,
autoSkip: true
})
var xhr = new XMLHttpRequest;
xhr.open("GET", "localhost.json");
xhr.responseType = "text";
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if ((xhr.status >= 200 && xhr.status < 300) || (xhr.status == 304)) {
let result = JSON.parse(xhr.responseText).result;
let music_list = []
for(let i = 0; i < result.length; i++){
music_list[music_list.length] = new Music(result[i].name, result[i].artist, result[i].cover, result[i].lrc, result[i].url)
}
fplayer.setMusicList(music_list);
} else {
//失败
}
}
}
xhr.send();
</script>
</body>
</html>