Skip to content

Commit 26947a2

Browse files
committed
New: Support background music from folder: MP3, M4A, WEBM, WEBA, OGG, OPUS, WAV, FLAC
1 parent 7aee55c commit 26947a2

28 files changed

+264
-18
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
88

99
##### 🚀 New Features
1010

11-
- Show error message if continue reading file does not exist
11+
- Show error message if continue reading file does not exist [`7aee55c`](https://github.com/ollm/OpenComic/commit/7aee55ca5dac6b937824728b7ded116dc00c28df)
12+
- Support background music from folder: MP3, M4A, WEBM, WEBA, OGG, OPUS, WAV, FLAC
1213

1314
##### 🐛 Bug Fixes
1415

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ More [Screenshots 📸](https://github.com/ollm/OpenComic/blob/master/SCREENSHOT
2727
- 🖼 Support this image formats: `JPG`, `PNG`, `APNG`, `AVIF`, `WEBP`, `GIF`, `SVG`, `BMP`, `ICO`
2828
- 🗄 Support this compressed formats: `RAR`, `ZIP`, `7Z`, `TAR`, `CBR`, `CBZ`, `CB7`, `CBT`
2929
- 📄 Support this documents/ebook formats: `PDF`, `EPUB` (Alpha)
30+
- 🎵 Support background music from folder: `MP3`, `M4A`, `WEBM`, `WEBA`, `OGG`, `OPUS`, `WAV`, `FLAC`
3031
- 📁 Master folders support
3132
- ☁️ Server connection support: `smb://`, `ftp://`, `ftps://`, `scp://`, `sftp://`, `ssh://`
3233
- 🇯🇵 Manga read mode

languages/ca.json

+4
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@
169169
"volumes": "Toms",
170170
"volume": "Tom"
171171
},
172+
"music": {
173+
"main": "Música",
174+
"volume": "Volum"
175+
},
172176
"moreOptions": {
173177
"main": "Més opcions",
174178
"hideBarHeader": "Amaga la barra superior",

languages/cs.json

+4
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@
169169
"volumes": "Svazky",
170170
"volume": "Svazek"
171171
},
172+
"music": {
173+
"main": "",
174+
"volume": ""
175+
},
172176
"moreOptions": {
173177
"main": "Více nastavení",
174178
"hideBarHeader": "Skrýt vrchní panel",

languages/de.json

+4
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@
169169
"volumes": "Ausgaben",
170170
"volume": "Ausgabe"
171171
},
172+
"music": {
173+
"main": "",
174+
"volume": ""
175+
},
172176
"moreOptions": {
173177
"main": "",
174178
"hideBarHeader": "",

languages/en.json

+4
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@
169169
"volumes": "Volumes",
170170
"volume": "Volume"
171171
},
172+
"music": {
173+
"main": "Music",
174+
"volume": "Volume"
175+
},
172176
"moreOptions": {
173177
"main": "More options",
174178
"hideBarHeader": "Hide header bar",

languages/es.json

+4
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@
169169
"volumes": "Tomos",
170170
"volume": "Tomo"
171171
},
172+
"music": {
173+
"main": "Música",
174+
"volume": "Volumen"
175+
},
172176
"moreOptions": {
173177
"main": "Más opciones",
174178
"hideBarHeader": "Ocultar barra superior",

languages/fr.json

+4
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@
169169
"volumes": "Volumes",
170170
"volume": "Volume"
171171
},
172+
"music": {
173+
"main": "",
174+
"volume": ""
175+
},
172176
"moreOptions": {
173177
"main": "",
174178
"hideBarHeader": "",

languages/hu.json

+4
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@
169169
"volumes": "Volumes",
170170
"volume": "Volume"
171171
},
172+
"music": {
173+
"main": "",
174+
"volume": ""
175+
},
172176
"moreOptions": {
173177
"main": "",
174178
"hideBarHeader": "",

languages/it.json

+4
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@
169169
"volumes": "",
170170
"volume": ""
171171
},
172+
"music": {
173+
"main": "",
174+
"volume": ""
175+
},
172176
"moreOptions": {
173177
"main": "",
174178
"hideBarHeader": "",

languages/ja.json

+4
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@
169169
"volumes": "",
170170
"volume": ""
171171
},
172+
"music": {
173+
"main": "",
174+
"volume": ""
175+
},
172176
"moreOptions": {
173177
"main": "",
174178
"hideBarHeader": "",

languages/pt-br.json

+4
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@
169169
"volumes": "",
170170
"volume": ""
171171
},
172+
"music": {
173+
"main": "",
174+
"volume": ""
175+
},
172176
"moreOptions": {
173177
"main": "",
174178
"hideBarHeader": "",

languages/ru.json

+4
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@
169169
"volumes": "Тома",
170170
"volume": "Том"
171171
},
172+
"music": {
173+
"main": "",
174+
"volume": ""
175+
},
172176
"moreOptions": {
173177
"main": "Дополнительные параметры",
174178
"hideBarHeader": "Скрыть панель заголовка",

languages/th.json

+4
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@
169169
"volumes": "เล่ม",
170170
"volume": "เล่ม"
171171
},
172+
"music": {
173+
"main": "",
174+
"volume": ""
175+
},
172176
"moreOptions": {
173177
"main": "ตัวเลือกเพิ่มเติม",
174178
"hideBarHeader": "ซ่อนแถบส่วนบน",

languages/vi.json

+4
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@
169169
"volumes": "Tập",
170170
"volume": "Tập"
171171
},
172+
"music": {
173+
"main": "",
174+
"volume": ""
175+
},
172176
"moreOptions": {
173177
"main": "Thêm tùy chọn",
174178
"hideBarHeader": "Ẩn thanh công cụ",

languages/zh-hans.json

+4
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@
169169
"volumes": "",
170170
"volume": ""
171171
},
172+
"music": {
173+
"main": "",
174+
"volume": ""
175+
},
172176
"moreOptions": {
173177
"main": "更多选项",
174178
"hideBarHeader": "隐藏标题栏",

languages/zh-hant.json

+4
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@
169169
"volumes": "",
170170
"volume": ""
171171
},
172+
"music": {
173+
"main": "",
174+
"volume": ""
175+
},
172176
"moreOptions": {
173177
"main": "",
174178
"hideBarHeader": "",

scripts/dom.js

+15-4
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
362362
onReading = _onReading = false;
363363

364364
reading.hideContent();
365+
reading.music.pause();
365366

366367
generateAppMenu();
367368

@@ -1904,6 +1905,15 @@ async function openComic(animation = true, path = true, mainPath = true, end = f
19041905
// Show loadign page
19051906
headerPath(path, mainPath);
19061907

1908+
// Load files
1909+
let file = fileManager.file(path);
1910+
let files = await file.read({filtered: false});
1911+
1912+
let hasMusic = await reading.music.has(files);
1913+
handlebarsContext.hasMusic = hasMusic;
1914+
1915+
files = fileManager.filtered(files);
1916+
19071917
handlebarsContext.comics = [];
19081918

19091919
if(fromDeepLoad && Date.now() - fromDeepLoadNow < 200)
@@ -1923,14 +1933,12 @@ async function openComic(animation = true, path = true, mainPath = true, end = f
19231933

19241934
template.loadContentLeft('reading.content.left.html', animation);
19251935

1926-
// Load files
1927-
let file = fileManager.file(path);
1928-
let files = await file.read();
1929-
19301936
let isCanvas = false;
19311937
let isEbook = false;
19321938
let compressedFile = fileManager.lastCompressedFile(path);
19331939

1940+
if(hasMusic) files.push(hasMusic); // Only to make available
1941+
19341942
if(compressedFile)
19351943
{
19361944
let features = fileManager.fileCompressed(compressedFile);
@@ -1957,6 +1965,8 @@ async function openComic(animation = true, path = true, mainPath = true, end = f
19571965
await file.makeAvailable(files, false, true);
19581966
}
19591967

1968+
if(hasMusic) files.pop(); // Remove now
1969+
19601970
file.destroy();
19611971

19621972
skipNextComic = await nextComic(path, mainPath);
@@ -2091,6 +2101,7 @@ async function openComic(animation = true, path = true, mainPath = true, end = f
20912101

20922102
reading.read(path, indexStart, end, isCanvas, isEbook, imagePath);
20932103
reading.hideContent(electronRemote.getCurrentWindow().isFullScreen(), true);
2104+
reading.music.read(hasMusic);
20942105

20952106
generateAppMenu();
20962107

scripts/file-manager.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ var file = function(path, config = false) {
471471

472472
let name = p.parse(path).name;
473473

474-
let regex = new RegExp('^(?:[\-\s0-9+])?(?:'+pregQuote(name)+(inside ? '|cover|default|folder|series|poster' : '')+')(?:[\-\s0-9+])?\.[a-z0-9]+$');
474+
let regex = new RegExp('^(?:[\-\s0-9+])?(?:'+pregQuote(name)+'(?:[_-]?(?:cover|default|folder|series|poster|thumbnail))?'+(inside ? '|cover|default|folder|series|poster|thumbnail' : '')+')(?:[\-\s0-9+])?\.[a-z0-9]+$');
475475
let poster = false;
476476

477477
let len = files.length

scripts/gamepad.js

+2
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ function showMenu()
704704
else
705705
events.activeMenu(query, false, 'gamepad');
706706

707+
dom.query('.gamepad-reading-music').css({display: !handlebarsContext.hasMusic ? 'none' : ''});
708+
707709
if(!onReading)
708710
{
709711
let viewIcon = document.querySelector('.menu-gamepad-view-icon');

scripts/opencomic.js

+13
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,19 @@ var compatibleSpecialExtensions = [
321321
'tbn',
322322
];
323323

324+
var audioExtensions = {
325+
all: [
326+
'mp3',
327+
'm4a',
328+
'webm',
329+
'weba',
330+
'ogg',
331+
'opus',
332+
'wav',
333+
'flac',
334+
],
335+
};
336+
324337
//console.time('Require time 2');
325338

326339
const app = require(p.join(appDir, 'scripts/app.js')),

scripts/reading.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const render = require(p.join(appDir, 'scripts/reading/render.js')),
22
filters = require(p.join(appDir, 'scripts/reading/filters.js')),
3+
music = require(p.join(appDir, 'scripts/reading/music.js')),
34
readingEbook = require(p.join(appDir, 'scripts/reading/ebook.js'));
45

56
var images = {}, imagesData = {}, imagesDataClip = {}, imagesPath = {}, imagesNum = 0, contentNum = 0, imagesNumLoad = 0, currentIndex = 1, imagesPosition = {}, imagesFullPosition = {}, foldersPosition = {}, indexNum = 0, imagesDistribution = [], currentPageXY = {x: 0, y: 0}, currentMousePosition = {pageX: 0, pageY: 0};
@@ -2103,7 +2104,7 @@ function fixBlurOnZoom(scale = 1, index = false)
21032104
img.style.width = (_width / window.devicePixelRatio)+'px';
21042105
img.style.height = (_height / window.devicePixelRatio)+'px';
21052106

2106-
if(img.classList.contains('blobRender'))
2107+
if(img.classList.contains('blobRender') || img.classList.contains('zoomOriginalSize') || img.classList.contains('originalSize'))
21072108
img.style.transform = 'scale('+_scale+') translate(0.001px, 0.001px)';
21082109
else
21092110
img.style.transform = 'scale('+_scale+')';
@@ -2120,7 +2121,7 @@ function fixBlurOnZoom(scale = 1, index = false)
21202121
{
21212122
let img = images[i];
21222123

2123-
if(!img.classList.contains('blobRender'))
2124+
if(!img.classList.contains('blobRender') && !img.classList.contains('zoomOriginalSize') && !img.classList.contains('originalSize'))
21242125
{
21252126
let rect = img.getBoundingClientRect();
21262127

@@ -5100,5 +5101,6 @@ module.exports = {
51005101
onLoad: onLoad,
51015102
ebook: readingEbook,
51025103
filters: filters,
5104+
music: music,
51035105
render: render,
51045106
};

0 commit comments

Comments
 (0)