Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikPeters committed Nov 16, 2024
2 parents c8778b6 + 6df383a commit 0267d14
Show file tree
Hide file tree
Showing 8 changed files with 869 additions and 534 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# MP3 Chapters Player

A simple desktop application to play MP3 files with chapters.
A simple desktop application to play MP3 files with chapters.

The player can also be started from the command line, by passing a path to the desired MP3 file.

```sh
"MP3 Chapter Player.exe" "c:\path\to\file.mp3"
```
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mp3chapters-player",
"private": true,
"version": "0.2.0",
"version": "0.3.0",
"type": "module",
"scripts": {
"tauri": "webpack --config webpack.tauri.config.js && tauri",
Expand Down
43 changes: 23 additions & 20 deletions src-app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,26 @@ import { invoke } from '@tauri-apps/api/tauri';
import { open } from '@tauri-apps/api/dialog';
import { appWindow } from "@tauri-apps/api/window";
import { convertFileSrc } from '@tauri-apps/api/tauri';
import { listen } from '@tauri-apps/api/event'
import { getMatches } from '@tauri-apps/api/cli';

import { loadFile } from '@common/FileLoader.js';
import { startUp } from '@common/Player.js';

function handleMP3FilePath(filePath) {
const url = convertFileSrc(filePath);
console.log("Opening file: " + url);
player.src = { src: url, type: 'audio/mpeg' };
loadFile(player, url);
const fileName = filePath.split('\\').pop().split('/').pop();
appWindow.setTitle(fileName);
}

listen('tauri://file-drop', event => {
console.log(event);
const filesDrop = event.payload;
for (let file of filesDrop) {
if (file.endsWith('.mp3')) {
const url = convertFileSrc(file);
console.log(url);
player.src = { src: url, type: 'audio/mpeg' };
loadFile(player, url);
const fileName = file.split('\\').pop().split('/').pop();
appWindow.setTitle(fileName);
handleMP3FilePath(file);
break;
}
}
Expand All @@ -37,12 +41,9 @@ async function openFile() {
],
});
console.log(selected);
const url = convertFileSrc(selected);
console.log(url);
player.src = { src: url, type: 'audio/mpeg' };
loadFile(player, url);
const fileName = selected.split('\\').pop().split('/').pop();
appWindow.setTitle(fileName);
if (selected) {
handleMP3FilePath(selected);
}
}

const unlisten = await appWindow.onMenuClicked(async ({ payload: menuId }) => {
Expand All @@ -56,11 +57,13 @@ const player = document.querySelector("media-player");

startUp();

window.addEventListener("DOMContentLoaded", async () => {
// greetInputEl = document.querySelector("#greet-input");
// greetMsgEl = document.querySelector("#greet-msg");
// document.querySelector("#greet-form").addEventListener("submit", (e) => {
// e.preventDefault();
// greet();
// });
// reading arguments from the command line
getMatches().then((matches) => {
console.log("Matches:");
console.log(matches);
window.matches = matches;
if (matches.args.filename.value) {
console.log(matches.args.filename.value);
handleMP3FilePath(matches.args.filename.value);
}
});
Loading

0 comments on commit 0267d14

Please sign in to comment.