-
Notifications
You must be signed in to change notification settings - Fork 1
/
secondScreen.html
149 lines (140 loc) · 4.91 KB
/
secondScreen.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
147
148
149
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>KaraokePlayerDemo - SecondScreen</title>
<link rel="stylesheet" href="css/lrc.css"/>
<script src="js/vue.min.js" type="text/javascript" charset="utf-8"></script>
<style>
*{
font-family: 'Microsoft YaHei',Arial,Helvetica,Sans-Serif;;
}
#app{
width: 100%;
height: 100%;
position: fixed;
border: 0;
margin: 0;
padding: 0;
left: 0;
top: 0;
}
.disconnect{
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
text-align: center;
display: flex;
align-items: center;
justify-content: center;
background-color: #16161680;
z-index: 999;
}
</style>
</head>
<body>
<div id="app">
<div style="position: fixed;top: 0;left: 0;width: 100%;height: calc(100%);text-align: center;z-index: 10;" >
<div>
<p style="text-align: left;font-size: 32px;margin-top: 0.5rem;margin-bottom: 0.5rem;margin-left: 0.4rem;">{{ SongInfo.title }}</p>
<p style="text-align: left;font-size: 16px;margin-top: 0.5rem;margin-bottom: 0rem;margin-left: 0.4rem;">{{ SongInfo.artist }}</p>
</div>
<div id="lrcSor" style="height: 240px;width: 100%;background-color: rgb(19 19 19 / 60%);overflow: hidden;display: flex;position: absolute;bottom: 0;justify-content: center;flex-direction: column;">
<div id="lasttimeprocess" style="align-self: center;margin: 0px auto;background-color: coral;height: 0rem;position: absolute;top: 0;width: 100%;"></div>
<div id="lasttime" style="align-self: center;margin: 0 auto;color: #FFFFFF;font-size: 1.8rem;font-family: fantasy;position: absolute;top: 1.2rem;display: none;">10 s</div>
<div id="lrcDomList" class="lrcdisplay">
</div>
</div>
</div>
<div class="disconnect" :style={display:(noping==true?'none':'flex')}>
<h1 style="color: white;">Disconnect</h1>
</div>
</div>
</body>
<script src="js/postcode.js"></script>
<script src="js/lyricParsingS.js"></script>
<script>
var vm = new Vue({
el: "#app",
data: {
SongInfo:{
title: 'KaraokePlayerDemo',
artist: '-',
album: '-',
},
noping: false,
}
});
</script>
<script>
let lrPar = new lyricParsingS({
LrcDom: "lrcDomList",
Debug:false, //调试模式
});
window.KaraokeWorker = new SharedWorker('js/karaokeWorker.js','KaraokeWorker');
var reloadOK = false;
window.onbeforeunload = () => {
window.KaraokeWorker.port.postMessage('SecondScreen Close');
};
function Workerbc(message) {
window.KaraokeWorker.port.postMessage(message);
}
Workerbc({
code:window.PostCode.Ping
});
let ds = 0;
setInterval(() => {
Workerbc({
code:window.PostCode.Ping
});
console.log("ping")
if(ds < 2) {
ds++
}
if(ds >= 2){
vm.$data.noping = false;
}
}, 1000);
window.KaraokeWorker.port.postMessage('SecondScreen Load');
window.KaraokeWorker.port.onmessage = (e) => {
if(typeof e.data == "object"){
switch (e.data.code) {
case window.PostCode.CreateNewSong:
reloadOK = false;
console.log("CreateNewSong");
lrPar.ReadLrc(e.data.oLrc,e.data.Lastlist);
console.log(e.data)
vm.$data.SongInfo.title = e.data.info.title;
vm.$data.SongInfo.artist = e.data.info.artist;
reloadOK = true;
break;
case window.PostCode.RefEvent:
if(!reloadOK) return;
lrPar.RefLrcDisplay(e.data.seek);
break;
case window.PostCode.ConfigChange:
lrPar.ClassicKaraoke = e.data.ClassicKaraoke
lrPar.LastTime = e.data.LastTime
lrPar.LastTimePer = e.data.LastTimePer
break;
case window.PostCode.Pong:
console.log(ds)
if(ds>0){
vm.$data.noping = true;
ds--
}
break;
default:
console.log(e.data);
break;
}
}else if(typeof e == "string"){
console.log(e.data);
}else{
console.log(e.data);
}
}
</script>
</html>