Skip to content

Commit

Permalink
New: Support background music from folder: MP3, M4A, WEBM, WEBA, OGG,…
Browse files Browse the repository at this point in the history
… OPUS, WAV, FLAC
  • Loading branch information
ollm committed Jan 19, 2024
1 parent 7aee55c commit 26947a2
Show file tree
Hide file tree
Showing 28 changed files with 264 additions and 18 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

##### 🚀 New Features

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

##### 🐛 Bug Fixes

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ More [Screenshots 📸](https://github.com/ollm/OpenComic/blob/master/SCREENSHOT
- 🖼 Support this image formats: `JPG`, `PNG`, `APNG`, `AVIF`, `WEBP`, `GIF`, `SVG`, `BMP`, `ICO`
- 🗄 Support this compressed formats: `RAR`, `ZIP`, `7Z`, `TAR`, `CBR`, `CBZ`, `CB7`, `CBT`
- 📄 Support this documents/ebook formats: `PDF`, `EPUB` (Alpha)
- 🎵 Support background music from folder: `MP3`, `M4A`, `WEBM`, `WEBA`, `OGG`, `OPUS`, `WAV`, `FLAC`
- 📁 Master folders support
- ☁️ Server connection support: `smb://`, `ftp://`, `ftps://`, `scp://`, `sftp://`, `ssh://`
- 🇯🇵 Manga read mode
Expand Down
4 changes: 4 additions & 0 deletions languages/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@
"volumes": "Toms",
"volume": "Tom"
},
"music": {
"main": "Música",
"volume": "Volum"
},
"moreOptions": {
"main": "Més opcions",
"hideBarHeader": "Amaga la barra superior",
Expand Down
4 changes: 4 additions & 0 deletions languages/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@
"volumes": "Svazky",
"volume": "Svazek"
},
"music": {
"main": "",
"volume": ""
},
"moreOptions": {
"main": "Více nastavení",
"hideBarHeader": "Skrýt vrchní panel",
Expand Down
4 changes: 4 additions & 0 deletions languages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@
"volumes": "Ausgaben",
"volume": "Ausgabe"
},
"music": {
"main": "",
"volume": ""
},
"moreOptions": {
"main": "",
"hideBarHeader": "",
Expand Down
4 changes: 4 additions & 0 deletions languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@
"volumes": "Volumes",
"volume": "Volume"
},
"music": {
"main": "Music",
"volume": "Volume"
},
"moreOptions": {
"main": "More options",
"hideBarHeader": "Hide header bar",
Expand Down
4 changes: 4 additions & 0 deletions languages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@
"volumes": "Tomos",
"volume": "Tomo"
},
"music": {
"main": "Música",
"volume": "Volumen"
},
"moreOptions": {
"main": "Más opciones",
"hideBarHeader": "Ocultar barra superior",
Expand Down
4 changes: 4 additions & 0 deletions languages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@
"volumes": "Volumes",
"volume": "Volume"
},
"music": {
"main": "",
"volume": ""
},
"moreOptions": {
"main": "",
"hideBarHeader": "",
Expand Down
4 changes: 4 additions & 0 deletions languages/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@
"volumes": "Volumes",
"volume": "Volume"
},
"music": {
"main": "",
"volume": ""
},
"moreOptions": {
"main": "",
"hideBarHeader": "",
Expand Down
4 changes: 4 additions & 0 deletions languages/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@
"volumes": "",
"volume": ""
},
"music": {
"main": "",
"volume": ""
},
"moreOptions": {
"main": "",
"hideBarHeader": "",
Expand Down
4 changes: 4 additions & 0 deletions languages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@
"volumes": "",
"volume": ""
},
"music": {
"main": "",
"volume": ""
},
"moreOptions": {
"main": "",
"hideBarHeader": "",
Expand Down
4 changes: 4 additions & 0 deletions languages/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@
"volumes": "",
"volume": ""
},
"music": {
"main": "",
"volume": ""
},
"moreOptions": {
"main": "",
"hideBarHeader": "",
Expand Down
4 changes: 4 additions & 0 deletions languages/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@
"volumes": "Тома",
"volume": "Том"
},
"music": {
"main": "",
"volume": ""
},
"moreOptions": {
"main": "Дополнительные параметры",
"hideBarHeader": "Скрыть панель заголовка",
Expand Down
4 changes: 4 additions & 0 deletions languages/th.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@
"volumes": "เล่ม",
"volume": "เล่ม"
},
"music": {
"main": "",
"volume": ""
},
"moreOptions": {
"main": "ตัวเลือกเพิ่มเติม",
"hideBarHeader": "ซ่อนแถบส่วนบน",
Expand Down
4 changes: 4 additions & 0 deletions languages/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@
"volumes": "Tập",
"volume": "Tập"
},
"music": {
"main": "",
"volume": ""
},
"moreOptions": {
"main": "Thêm tùy chọn",
"hideBarHeader": "Ẩn thanh công cụ",
Expand Down
4 changes: 4 additions & 0 deletions languages/zh-hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@
"volumes": "",
"volume": ""
},
"music": {
"main": "",
"volume": ""
},
"moreOptions": {
"main": "更多选项",
"hideBarHeader": "隐藏标题栏",
Expand Down
4 changes: 4 additions & 0 deletions languages/zh-hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@
"volumes": "",
"volume": ""
},
"music": {
"main": "",
"volume": ""
},
"moreOptions": {
"main": "",
"hideBarHeader": "",
Expand Down
19 changes: 15 additions & 4 deletions scripts/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
onReading = _onReading = false;

reading.hideContent();
reading.music.pause();

generateAppMenu();

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

// Load files
let file = fileManager.file(path);
let files = await file.read({filtered: false});

let hasMusic = await reading.music.has(files);
handlebarsContext.hasMusic = hasMusic;

files = fileManager.filtered(files);

handlebarsContext.comics = [];

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

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

// Load files
let file = fileManager.file(path);
let files = await file.read();

let isCanvas = false;
let isEbook = false;
let compressedFile = fileManager.lastCompressedFile(path);

if(hasMusic) files.push(hasMusic); // Only to make available

if(compressedFile)
{
let features = fileManager.fileCompressed(compressedFile);
Expand All @@ -1957,6 +1965,8 @@ async function openComic(animation = true, path = true, mainPath = true, end = f
await file.makeAvailable(files, false, true);
}

if(hasMusic) files.pop(); // Remove now

file.destroy();

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

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

generateAppMenu();

Expand Down
2 changes: 1 addition & 1 deletion scripts/file-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ var file = function(path, config = false) {

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

let regex = new RegExp('^(?:[\-\s0-9+])?(?:'+pregQuote(name)+(inside ? '|cover|default|folder|series|poster' : '')+')(?:[\-\s0-9+])?\.[a-z0-9]+$');
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]+$');
let poster = false;

let len = files.length
Expand Down
2 changes: 2 additions & 0 deletions scripts/gamepad.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,8 @@ function showMenu()
else
events.activeMenu(query, false, 'gamepad');

dom.query('.gamepad-reading-music').css({display: !handlebarsContext.hasMusic ? 'none' : ''});

if(!onReading)
{
let viewIcon = document.querySelector('.menu-gamepad-view-icon');
Expand Down
13 changes: 13 additions & 0 deletions scripts/opencomic.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,19 @@ var compatibleSpecialExtensions = [
'tbn',
];

var audioExtensions = {
all: [
'mp3',
'm4a',
'webm',
'weba',
'ogg',
'opus',
'wav',
'flac',
],
};

//console.time('Require time 2');

const app = require(p.join(appDir, 'scripts/app.js')),
Expand Down
6 changes: 4 additions & 2 deletions scripts/reading.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const render = require(p.join(appDir, 'scripts/reading/render.js')),
filters = require(p.join(appDir, 'scripts/reading/filters.js')),
music = require(p.join(appDir, 'scripts/reading/music.js')),
readingEbook = require(p.join(appDir, 'scripts/reading/ebook.js'));

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};
Expand Down Expand Up @@ -2103,7 +2104,7 @@ function fixBlurOnZoom(scale = 1, index = false)
img.style.width = (_width / window.devicePixelRatio)+'px';
img.style.height = (_height / window.devicePixelRatio)+'px';

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

if(!img.classList.contains('blobRender'))
if(!img.classList.contains('blobRender') && !img.classList.contains('zoomOriginalSize') && !img.classList.contains('originalSize'))
{
let rect = img.getBoundingClientRect();

Expand Down Expand Up @@ -5100,5 +5101,6 @@ module.exports = {
onLoad: onLoad,
ebook: readingEbook,
filters: filters,
music: music,
render: render,
};

0 comments on commit 26947a2

Please sign in to comment.