Unverified Commit 3fdff865 authored by Wolle's avatar Wolle Committed by GitHub

added another level

parent a80c6068
......@@ -2,7 +2,7 @@
* index.h
*
* Created on: 13.12.2022
* Updated on:
* Updated on: 20.12.2022
* Author: Wolle
*
* ESP32 - DLNA
......@@ -107,7 +107,7 @@ function connect() {
if (n >= 0) {
var msg = socketMsg.substring(0, n)
var val = socketMsg.substring(n + 1)
// console.log("para ",msg, " val ",val)
// console.log("para ",msg, " val ",val)
}
else {
msg = socketMsg
......@@ -118,14 +118,16 @@ function connect() {
break
case "DLNA_Names": showServer(val)
break
case "Level0": show_DLNA_Content(val, 0)
break
case "Level1": show_DLNA_Content(val, 1)
break
case "Level2": show_DLNA_Content(val, 2)
break
case "Level3": show_DLNA_Content(val, 3)
break
case "Level4": show_DLNA_Content(val, 4)
break
case "Level5": show_DLNA_Content(val, 5)
break
default: console.log('unknown message', msg, val)
}
}
......@@ -167,10 +169,11 @@ function showServer(val){
function show_DLNA_Content(val, level){
var select
if(level == 0) select = document.getElementById('level1')
if(level == 1) select = document.getElementById('level2')
if(level == 2) select = document.getElementById('level3')
if(level == 3) select = document.getElementById('level4')
if(level == 1) select = document.getElementById('level1')
if(level == 2) select = document.getElementById('level2')
if(level == 3) select = document.getElementById('level3')
if(level == 4) select = document.getElementById('level4')
if(level == 5) select = document.getElementById('level5')
content =JSON.parse(val)
//console.log(ct[1].name)
select.options.length = 0;
......@@ -184,11 +187,11 @@ function show_DLNA_Content(val, level){
var n
var c
if(content[i].isDir == true){
n = content[i].name + ' <DIR>';
n = content[i].name.concat('\xa0\xa0', '<DIR>'); // more than one space
c = 'D=' + content[i].id // is directory
}
else{
n = content[i].name + ' ' + content[i].size;
n = content[i].name + '\xa0\xa0' + content[i].size;
c = 'F=' + content[i].id // is file
}
opt.value = c
......@@ -198,41 +201,51 @@ function show_DLNA_Content(val, level){
}
}
function selectserver (presctrl) { // preset, select a server
function selectserver (presctrl) { // preset, select a server, root, level0
socket.send('DLNA_getContent0=' + presctrl.value)
select = document.getElementById('level1'); select.options.length = 0; // clear next level
select = document.getElementById('level2'); select.options.length = 0;
select = document.getElementById('level3'); select.options.length = 0;
select = document.getElementById('level4'); select.options.length = 0;
select = document.getElementById('level5'); select.options.length = 0;
console.log('DLNA_getContent0=' + presctrl.value)
}
function select_l0 (presctrl) { // preset, select root
function select_l1 (presctrl) { // preset, select root
socket.send('DLNA_getContent1=' + presctrl.value)
select = document.getElementById('level2'); select.options.length = 0; // clear next level
select = document.getElementById('level3'); select.options.length = 0;
select = document.getElementById('level4'); select.options.length = 0;
select = document.getElementById('level5'); select.options.length = 0;
console.log('DLNA_getContent1=' + presctrl.value)
}
function select_l1 (presctrl) { // preset, select level 1
function select_l2 (presctrl) { // preset, select level 1
socket.send('DLNA_getContent2=' + presctrl.value)
select = document.getElementById('level3'); select.options.length = 0;
select = document.getElementById('level4'); select.options.length = 0;
select = document.getElementById('level5'); select.options.length = 0;
console.log('DLNA_getContent2=' + presctrl.value)
}
function select_l2 (presctrl) { // preset, select level 2
function select_l3 (presctrl) { // preset, select level 2
socket.send('DLNA_getContent3=' + presctrl.value)
select = document.getElementById('level4'); select.options.length = 0;
select = document.getElementById('level5'); select.options.length = 0;
console.log('DLNA_getContent3=' + presctrl.value)
}
function select_l3 (presctrl) { // preset, select level 3
function select_l4 (presctrl) { // preset, select level 3
socket.send('DLNA_getContent4=' + presctrl.value)
select = document.getElementById('level5'); select.options.length = 0;
console.log('DLNA_getContent4=' + presctrl.value)
}
function select_l5 (presctrl) { // preset, select level 4
socket.send('DLNA_getContent5=' + presctrl.value)
console.log('DLNA_getContent5=' + presctrl.value)
}
</script>
<body id="BODY">
<!--==============================================================================================-->
......@@ -246,16 +259,19 @@ function select_l2 (presctrl) { // preset, select level 2
<select class="boxstyle" style="width: 100%;" onchange="selectserver(this)" id="server">
<option value="-1">Select a DLNA Server here</option>
</select>
<select class="boxstyle" style="width: 100%; margin-top: 5px;" onchange="select_l0(this)" id="level1">
<select class="boxstyle" style="width: 100%; margin-top: 5px;" onchange="select_l1(this)" id="level1">
<option value="-1"> </option>
</select>
<select class="boxstyle" style="width: 100%; margin-top: 5px;" onchange="select_l1(this)" id="level2">
<select class="boxstyle" style="width: 100%; margin-top: 5px;" onchange="select_l2(this)" id="level2">
<option value="-1"> </option>
</select>
<select class="boxstyle" style="width: 100%; margin-top: 5px;" onchange="select_l3(this)" id="level3">
<option value="-1"> </option>
</select>
<select class="boxstyle" style="width: 100%; margin-top: 5px;" onchange="select_l2(this)" id="level3">
<select class="boxstyle" style="width: 100%; margin-top: 5px;" onchange="select_l4(this)" id="level4">
<option value="-1"> </option>
</select>
<select class="boxstyle" style="width: 100%; margin-top: 5px;" onchange="select_l3(this)" id="level4">
<select class="boxstyle" style="width: 100%; margin-top: 5px;" onchange="select_l5(this)" id="level5">
<option value="-1"> </option>
</select>
</div>
......
......@@ -14,8 +14,8 @@ using namespace std;
#define I2S_LRC 26
char SSID[] = "*****";
char PASS[] = "*****";
char SSID[] = "Wolles-FRITZBOX";
char PASS[] = "40441061073895958449";
......@@ -51,6 +51,7 @@ void DLNA_showServer(){ // Show connection details of all discovered, usable med
if(i < numServers - 1) msg += ',';
names.push_back(srv.friendlyName);
}
log_i("msg %s", msg.c_str());
webSrv.send(msg);
}
void DLNA_browseServer(String objectId, uint8_t level){
......@@ -69,7 +70,7 @@ void DLNA_browseServer(String objectId, uint8_t level){
log_i("no content!"); // then the directory is empty
return;
}
log_i("objectID: %s", objectId.c_str());
log_v("objectID: %s", objectId.c_str());
for (int i = 0; i < browseResult.size(); i++){
object = browseResult[i];
myObject[i]["name"]= object.name;
......@@ -84,12 +85,13 @@ void DLNA_browseServer(String objectId, uint8_t level){
}
myObject[i]["size"] = (uint32_t)object.size;
myObject[i]["uri"] = object.id;
log_i("objectName %s", browseResult[i].name.c_str());
log_i("objectId %s", browseResult[i].artist.c_str());
log_v("objectName %s", browseResult[i].name.c_str());
log_v("objectId %s", browseResult[i].artist.c_str());
}
level++;
String msg = "Level" + String(level,10) + "=" + JSON.stringify(myObject);
log_i("msg = %s", msg.c_str());
log_v("msg = %s", msg.c_str());
webSrv.send(msg);
browseResult.clear();
}
......@@ -97,15 +99,15 @@ void DLNA_browseServer(String objectId, uint8_t level){
void DLNA_getFileItems(String uri){
soapObjectVect_t browseResult;
log_i("uri: %s", uri.c_str());
log_w("downloadIP: %s", media_downloadIP.c_str());
log_w("downloadport: %d", media_downloadPort);
log_v("uri: %s", uri.c_str());
log_v("downloadIP: %s", media_downloadIP.c_str());
log_v("downloadport: %d", media_downloadPort);
String URL = "http://" + media_downloadIP + ":" + media_downloadPort + "/" + uri;
log_i("URL=%s", URL.c_str());
audio.connecttohost(URL.c_str());
}
void DLNA_showContent(String objectId, uint8_t level){
log_i("obkId=%s", objectId.c_str());
log_v("obkId=%s", objectId.c_str());
if(level == 0){
DLNA_browseServer(objectId, level);
}
......@@ -157,6 +159,7 @@ void WEBSRV_onCommand(const String cmd, const String param, const String arg){
if(cmd == "DLNA_getContent2"){DLNA_showContent(param, 2); return;} // search for level 2 content
if(cmd == "DLNA_getContent3"){DLNA_showContent(param, 3); return;} // search for level 3 content
if(cmd == "DLNA_getContent4"){DLNA_showContent(param, 4); return;} // search for level 4 content
if(cmd == "DLNA_getContent5"){DLNA_showContent(param, 5); return;} // search for level 5 content
log_e("unknown HTMLcommand %s, param=%s", cmd.c_str(), param.c_str());
}
void WEBSRV_onRequest(const String request, uint32_t contentLength){
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment