-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
executable file
·218 lines (210 loc) · 7.81 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<!DOCTYPE html>
<html>
<head>
<title>Web Karaoke Player</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Web Karaoke Player. A Web based Karaoke/MIDI player based on WEbMIDIAPI and WebAudio Soundfonts">
<meta property="og:title" content="Web Karaoke Player"/>
<meta property="og:description" content="Web Karaoke Player. A Web based Karaoke/MIDI player based on WEbMIDIAPI and WebAudio Soundfonts"/>
<meta property="og:site_name" content="Web Karaoke Player"/>
<meta property="og:type" content="article"/>
<meta property="fb:appid" content="2162202714030310" >
<meta property="og:url" content="https://fraigo.github.io/karaoke-player/"/>
<link rel="canonical" href="https://fraigo.github.io/karaoke-player/" />
<meta property="og:image" content="http://fraigo.github.io/karaoke-player/screenshots/webkaraoke01.png"/>
<meta property="og:image:width" content="1000"/>
<meta property="og:image:height" content="542"/>
<script src="assets/js/midiplayer/WebAudioFontPlayer.js" ></script>
<script src="assets/js/midiplayer/MIDIFile.js" ></script>
<script src="assets/js/midiplayer/MIDIPlayer.js" ></script>
<script src="assets/js/midifile/MIDIFileHeader.js" ></script>
<script src="assets/js/KarFile.js" ></script>
<link rel="stylesheet" href="themes/basic/theme.css" >
<link rel="stylesheet" href="themes/sunset/theme.css" >
<link rel="stylesheet" href="themes/christmas/theme.css" >
<link rel="stylesheet" href="assets/css/karaoke.css" >
<link rel="stylesheet" href="assets/css/range.css" >
<link rel="shortcut icon" href="assets/images/icon.png" >
</head>
<body onload="" class="hidden" onunload="stop()">
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = 'https://connect.facebook.net/es_LA/sdk.js#xfbml=1&version=v3.2&appId=733529263442976&autoLogAppEvents=1';
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="toolbar">
<div class="app-title">
<img src="assets/images/icon.png" height="32" align="absmiddle">Karaoke Player
<div class="fb-share-button" data-layout="button_count" data-size="small" data-mobile-iframe="true">
<a target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ffraigo.github.io%2Fkaraoke-player%2F&src=sdkpreparse" class="fb-xfbml-parse-ignore">Compartir</a>
</div>
</div>
<div class="playback-toolbar">
<input type=file id="inputfile" accept=".mid,.midi,.kar" onchange=readKar(this) style="display:none" >
<button type="button" onclick="document.getElementById('inputfile').click()">Open File</button>
<button type="button" onclick="player.play()">Play</button>
<button type="button" onclick="player.pause()">Pause</button>
<button type="button" onclick="player.stop()">Stop</button>
<input id="position" type="range" min="0" max="100" value="0" onchange="console.log(this.value)">
<span id="time" >0:00</span>
</div>
</div>
<div id=karaoke class="player karaoke">
<span class="previous">***</span><br>
<span class="inactive">Karaoke </span><span class="active">Player</span><br>
<span class="next">***</span>
</div>
<div id="themes" class="dialog hidden">
<div class="dialog-content">
<h3>Select Theme</h3>
<div class="option basic" onclick="document.location='#basic'">
<div class="karaoke">
<span class="previous">Basic</span>
<br>
<span class="active">Basic</span>
</div>
</div>
<div class="option sunset" onclick="document.location='#sunset'">
<div class="karaoke">
<span class="previous">Sunset</span>
<br>
<span class="active">Sunset</span>
</div>
</div>
<div class="option christmas" onclick="document.location='#christmas'">
<div class="karaoke">
<span class="previous">Christmas</span>
<br>
<span class="active">Christmas</span>
</div>
</div>
</div>
</div>
<div id="songs" class="dialog hidden">
<div class="dialog-content" style="float: right;">
<h3 class="list-header">Select Song</h3>
<div id="songlist">
<div class="Song" >Loading...</div>
</div>
</div>
</div>
<div id="footer" class="footer">
<button id="themebutton" type="button" onclick="openDialog('themes')">Theme</button>
<div id="footer-text" class="footer-text">Karaoke Player by Francisco Igor</div>
<button id="songbutton" type="button" onclick="openDialog('songs')">Song List</button>
</div>
<pre id=result style="display:none"></pre>
<script src="assets/js/player.js"></script>
<script src="config.js"></script>
<script>
window.onload=function(){
var pos= document.getElementById("position");
var time1= document.getElementById("time");
pos.oninput=function(ev){
pos.changing = true
clearTimeout(pos.timeout)
pos.timeout = setTimeout(function(){
pos.changing = false
},300)
}
pos.onchange=function(ev){
console.log(pos.value);
player.setPosition(pos.value*1);
}
window.onhashchange();
player = new MIDIPlayer('inputfile');
// creating the MidiFile instance from a buffer (view MIDIFile README)
player.onload=function(song){
player.play();
pos.setAttribute("max",song.duration)
}
player.ontick=function(song, position){
if (!pos.changing) pos.value=position;
var sec = Math.round(pos.value)%60
if (sec<10) sec = '0'+sec
var min = Math.floor(pos.value/60)
time1.innerText = min+':'+sec
}
}
window.onblur=function(){
console.log("Blur", new Date())
player.pause();
}
window.onfocus=function(){
console.log("Focus", new Date())
player.play();
}
window.onhashchange=function(){
var hash=document.location.hash;
var themes=[
"#sunset",
"#basic",
"#christmas",
"#none",
]
if (themes.indexOf(hash)>=0){
document.body.className=hash.substring(1);
}else{
document.body.className=window.defaultTheme?defaultTheme:themes[0];
}
document.getElementById("themes").className="dialog hidden";
}
function openDialog(id){
var dialog=document.getElementById(id);
console.log(dialog.className);
if (dialog.className=="dialog hidden"){
var dialogs=document.getElementsByClassName("dialog visible");
if (dialogs.length) dialogs[0].className="dialog hidden";
dialog.className="dialog visible";
}else{
dialog.className="dialog hidden";
}
}
function loadSong(obj){
playUrl(obj.playlistPath,obj.filename+'.kar');
document.getElementById("songs").className="dialog hidden";
}
function loadUrl(url){
var corsProxy = "https://python-cors-proxy.herokuapp.com/"
var urlParts = url.split('/')
var baseName = urlParts.pop()
var baseUrl = corsProxy + "?url=" + urlParts.join('/') + '/'
console.log('loadUrl', baseUrl, baseName)
playUrl(baseUrl,baseName)
}
function loadPlaylist(playlistPath){
fetch(playlistPath+'playlist.json')
.then(function(response) {
return response.json();
})
.then(function(data) {
console.log(data);
var list=document.getElementById("songlist");
list.innerHTML="";
for(var i=0; i<data.length; i++){
var div=document.createElement("div");
div.innerHTML=data[i];
div.className="song";
div.playlistPath=playlistPath;
div.filename=data[i];
div.setAttribute("onclick","loadSong(this)")
list.appendChild(div);
}
});
}
if (document.location.search.length>1){
var path = document.location.search.substring(1)
var ext = path.substring(path.length-4)
if (path.indexOf("http")==0 && (ext=='.kar'||ext==".mid")){
loadUrl(path)
} else {
playlistPath=path;
}
}
loadPlaylist(window.playlistPath);
</script>
</body>
</html>