Skip to content

Commit 6caf9f4

Browse files
committed
New: Play background music also from parent folder
1 parent 4c40712 commit 6caf9f4

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

scripts/dom.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2188,7 +2188,7 @@ async function openComic(animation = true, path = true, mainPath = true, end = f
21882188
return;
21892189
}
21902190

2191-
let hasMusic = await reading.music.has(files);
2191+
let hasMusic = await reading.music.has(files, p.dirname(path));
21922192
handlebarsContext.hasMusic = hasMusic;
21932193

21942194
files = fileManager.filtered(files);

scripts/reading/music.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
let current = false, audio = false;
22

3-
async function has(files)
3+
async function has(files, findParent = false)
44
{
55
for(let i = 0, len = files.length; i < len; i++)
66
{
@@ -10,6 +10,28 @@ async function has(files)
1010
return _file;
1111
}
1212

13+
if(findParent)
14+
{
15+
const file = fileManager.file(findParent);
16+
let files = [];
17+
18+
try
19+
{
20+
files = await file.read({filtered: false});
21+
}
22+
catch(error)
23+
{
24+
console.error(error);
25+
dom.compressedError(error);
26+
27+
return false;
28+
}
29+
30+
file.destroy();
31+
32+
return has(files);
33+
}
34+
1335
return false;
1436
}
1537

0 commit comments

Comments
 (0)