forked from Edzelf/ESP32-Radio
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mp3play_html.h
83 lines (81 loc) · 2.49 KB
/
mp3play_html.h
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
// index.html file in raw data format for PROGMEM
//
#define mp3play_html_version 170703
const char mp3play_html[] PROGMEM = R"=====(
<!DOCTYPE html>
<html>
<head>
<title>ESP32-radio</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="radio.css">
<link rel="Shortcut Icon" type="image/ico" href="favicon.ico">
</head>
<body>
<ul>
<li><a class="pull-left" href="#">ESP32 Radio</a></li>
<li><a class="pull-left" href="/index.html">Control</a></li>
<li><a class="pull-left" href="/config.html">Config</a></li>
<li><a class="pull-left active" href="/mp3play.html">MP3 player</a></li>
<li><a class="pull-left" href="/about.html">About</a></li>
</ul>
<br><br><br>
<center>
<h1>** ESP32 Radio **</h1>
<label for="seltrack"><big>MP3 files on SD card:</big></label>
<br>
<select class="select selectw" onChange="trackreq(this)" id="seltrack">
<option value="-1">Select a track here</option>
</select>
<br><br>
<button class="button" onclick="httpGet('mp3track=0')">RANDOM</button>
<br><br>
<br>
<input type="text" width="600px" size="120" id="resultstr" placeholder="Waiting for a command...."><br>
<br><br>
</center>
<script>
function httpGet ( theReq )
{
var theUrl = "/?" + theReq + "&version=" + Math.random() ;
var xhr = new XMLHttpRequest() ;
xhr.onreadystatechange = function() {
if ( xhr.readyState == XMLHttpRequest.DONE )
{
resultstr.value = xhr.responseText ;
}
}
xhr.open ( "GET", theUrl ) ;
xhr.send() ;
}
function trackreq ( presctrl )
{
if ( presctrl.value != "-1" )
{
httpGet ( "mp3track=" + presctrl.value ) ;
}
}
// Fill track list initially
//
var i, select, opt, tracks, strparts ;
select = document.getElementById("seltrack") ;
var theUrl = "/?mp3list" ;
var xhr = new XMLHttpRequest() ;
xhr.onreadystatechange = function(){
if ( xhr.readyState == XMLHttpRequest.DONE )
{
tracks = xhr.responseText.split ( "\n" ) ;
for ( i = 0 ; i < ( tracks.length - 1 ) ; i++ ){
opt = document.createElement( "OPTION" ) ;
strparts = tracks[i].split ( "/" ) ;
opt.value = strparts[0] ;
opt.text = strparts[1] ;
select.add( opt ) ;
}
}
}
xhr.open ( "GET", theUrl, false ) ;
xhr.send() ;
</script>
</body>
</html>
)=====" ;