Skip to content

Commit

Permalink
New: Play background music also from parent folder
Browse files Browse the repository at this point in the history
  • Loading branch information
ollm committed Sep 26, 2024
1 parent 4c40712 commit 6caf9f4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -2188,7 +2188,7 @@ async function openComic(animation = true, path = true, mainPath = true, end = f
return;
}

let hasMusic = await reading.music.has(files);
let hasMusic = await reading.music.has(files, p.dirname(path));
handlebarsContext.hasMusic = hasMusic;

files = fileManager.filtered(files);
Expand Down
24 changes: 23 additions & 1 deletion scripts/reading/music.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
let current = false, audio = false;

async function has(files)
async function has(files, findParent = false)
{
for(let i = 0, len = files.length; i < len; i++)
{
Expand All @@ -10,6 +10,28 @@ async function has(files)
return _file;
}

if(findParent)
{
const file = fileManager.file(findParent);
let files = [];

try
{
files = await file.read({filtered: false});
}
catch(error)
{
console.error(error);
dom.compressedError(error);

return false;
}

file.destroy();

return has(files);
}

return false;
}

Expand Down

0 comments on commit 6caf9f4

Please sign in to comment.