initial commit
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.vscode/
|
||||
dist/
|
||||
46
build.sh
Executable file
46
build.sh
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "This script will remove / overwrite the content of some \"dist/\" directories."
|
||||
read -p "Do you want to continue ? [y/N]: " -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
echo "Aborted"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function clean {
|
||||
rm -rf ./frontend/dist && rm -rf ./backend/dist && rm -rf ./dist
|
||||
}
|
||||
|
||||
function build_frontend {
|
||||
dir=$(pwd)
|
||||
cd frontend
|
||||
npm run build
|
||||
cd "$dir"
|
||||
}
|
||||
|
||||
function build_backend {
|
||||
deno run --allow-read=./frontend/dist,./dist --allow-write=./dist ./bundle.ts ./frontend/dist ./dist/bundled-view-files.json
|
||||
cp ./dist/bundled-view-files.json ./backend/src/modules/view/bundled-view-files.json
|
||||
}
|
||||
|
||||
function compile_for {
|
||||
target=$1
|
||||
mkdir -p "./dist/bin"
|
||||
deno compile --target "$target" --output "./dist/bin/$target" --allow-net --allow-read --allow-write --allow-sys ./backend/src/main.ts
|
||||
}
|
||||
|
||||
function compile_all {
|
||||
compile_for x86_64-unknown-linux-gnu
|
||||
compile_for aarch64-unknown-linux-gnu
|
||||
compile_for x86_64-pc-windows-msvc
|
||||
compile_for x86_64-apple-darwin
|
||||
compile_for aarch64-apple-darwin
|
||||
}
|
||||
|
||||
|
||||
clean
|
||||
build_frontend
|
||||
build_backend
|
||||
compile_all
|
||||
59
bundle.ts
Normal file
59
bundle.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import { encodeBase64 } from 'https://deno.land/std@0.224.0/encoding/base64.ts';
|
||||
import { ensureFile } from 'https://deno.land/std@0.224.0/fs/mod.ts';
|
||||
|
||||
/**
|
||||
* { [path]: base64EncodedContent }
|
||||
*/
|
||||
type StaticFilesRecord = Record<string, string>;
|
||||
|
||||
/**
|
||||
* Traverse a directory recursively, adding every base64 encoded file content to the record.
|
||||
*
|
||||
* @param staticFileRecord the record in which to add base64 encoded file content
|
||||
* @param root the path of the root directory for traversal, that should not be included in the record file path
|
||||
* @param subdir the current subdir to traverse
|
||||
*/
|
||||
async function traverse(
|
||||
staticFileRecord: StaticFilesRecord,
|
||||
root: string,
|
||||
subdir: string = '',
|
||||
) {
|
||||
for await (const dirEntry of Deno.readDir(`${root}/${subdir}`)) {
|
||||
const path = `${subdir}/${dirEntry.name}`.slice(1);
|
||||
console.log(`encoding: ${path}`);
|
||||
if (dirEntry.isDirectory) {
|
||||
await traverse(staticFileRecord, root, `${subdir}/${dirEntry.name}`);
|
||||
} else {
|
||||
staticFileRecord[path] = encodeBase64(
|
||||
await Deno.readFile(
|
||||
`${root}/${subdir}/${dirEntry.name}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bundle all files of the given directory into a single json file at the given path.
|
||||
*
|
||||
* @param sourceDir path of the directory to bundle
|
||||
* @param bundleFilePath path of the json file
|
||||
*/
|
||||
async function buildFromDir(
|
||||
sourceDir: string,
|
||||
bundleFilePath: string,
|
||||
) {
|
||||
const staticFiles: StaticFilesRecord = {};
|
||||
await traverse(staticFiles, sourceDir);
|
||||
|
||||
await ensureFile(bundleFilePath);
|
||||
await Deno.writeTextFile(bundleFilePath, JSON.stringify(staticFiles));
|
||||
}
|
||||
|
||||
if (Deno.args.length !== 2) {
|
||||
console.error('Incorrect usage: Two parameters expected !');
|
||||
console.error('<script> view-dist-directory json-bundle-file');
|
||||
Deno.exit(1);
|
||||
}
|
||||
|
||||
await buildFromDir(Deno.args[0], Deno.args[1]);
|
||||
41
readme.md
Normal file
41
readme.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# Audio diffusion web manager
|
||||
|
||||
A program that provides a way to diffuse audio over multiple devices on a local network.
|
||||
|
||||
## Usage
|
||||
|
||||
1. Download the executable corresponding to your OS (Windows / Linux / Mac) here.
|
||||
2. Run the program and take note of the given web address.
|
||||
3. Open this address in a browser (Firefox / Chrome / ...).
|
||||
4. Use the interface to upload files, create device groups, assignate devices to groups, start diffusion, ...
|
||||
|
||||
## Project status
|
||||
|
||||
This project was done as a way to relearn how to use some tools / libraries / ...
|
||||
|
||||
As such, there is no garanty that it will be maintained and / or improved (despite the current lack of basic features - such as playlists).
|
||||
|
||||
That is, if you found a bug, need a feature or have an improvement idea, feel free to send it to open a ticket.
|
||||
|
||||
### Known bug
|
||||
|
||||
#### Audio is out of sync
|
||||
|
||||
Currently only the device clock is used for audio synchronisation.
|
||||
If a device clock is even slightly wrong, the audio will be as well.
|
||||
|
||||
Forcing the update of the device clock may solve the issue, but a better way would be to implement a delay detection as well as a way to manually set a device delay.
|
||||
|
||||
### Possible improvements
|
||||
|
||||
- Queuing more than one audio file
|
||||
- Setting device playback volume
|
||||
- Setting device delay manually
|
||||
- Detecting device delay automatically
|
||||
- Description of device connexion state (not connected / active / timeout)
|
||||
- Uploading file by drag and drop
|
||||
- Uploading many files at once
|
||||
|
||||
## License
|
||||
|
||||
TODO
|
||||
Reference in New Issue
Block a user