Skip to content

Commit

Permalink
Merge pull request #90 from muzik-apps/working
Browse files Browse the repository at this point in the history
v0.7.0-Audio Freedom Lab🥼
  • Loading branch information
waveyboym authored Dec 7, 2024
2 parents e94951b + 93bfb7a commit b3376cf
Show file tree
Hide file tree
Showing 71 changed files with 2,765 additions and 617 deletions.
9 changes: 9 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Describe your changes

## Issue ticket number and link

## Checklist before requesting a review
- [ ] I have performed a self-review of my code
- [ ] If it is a core feature, I have added thorough tests.
- [ ] Do we need to implement analytics?
- [ ] Will this be part of a product update? If yes, please write one phrase about this update.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version.
releaseName: 'v__VERSION__-Speeding things up(patch)'
releaseName: 'v__VERSION__-Audio Freedom Lab🥼'
releaseBody: 'See the assets to download this version and install.'
releaseDraft: true
prerelease: false
Expand Down
35 changes: 23 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ A cross platform, local music player that is an offline(no streaming) version of
# I am a developer
## Development Cycle
1. Download <a href="https://tauri.app/v1/guides/getting-started/prerequisites">the pre-requisites</a> for tauri only by following the pre-requisites page for your operating system.
2. If you are on linux OS(debian/ubuntu), run
2. If you are on a linux based OS, run
```
sudo apt-get install libasound2-dev
```
3. Clone this repo, specifically the <a href="https://github.com/muzik-apps/muzik-offline">main-app-dev</a> branch
3. Clone this repo or fork it and clone it.
4. run
```
cd muzik-offline/muzik-offline
Expand All @@ -55,45 +55,45 @@ cd muzik-offline/muzik-offline
```
npm install
```
6. This project uses <a href="https://discord.com/developers/docs/rich-presence/how-to">discord rpc</a>, so you will need a client id, otherwise the code won't compile
6. This application uses <a href="https://discord.com/developers/docs/rich-presence/how-to">discord rpc</a>, so you will need a client id, otherwise the application won't run
7. To get a client id, setup a new application on <a href="https://discord.com/developers/applications">discord developer portal</a> and then place your client id in an ```.env``` file in the <a href="https://github.com/muzik-apps/muzik-offline/tree/main-app-dev/muzik-offline/src-tauri">src-tauri</a> directory
8. The env file should look like this:
```
DISCORD_CLIENT_ID=<Your client id goes here>
```
9. If you are on linux/macos or any unix based OS, please navigate to <a href="https://github.com/muzik-apps/muzik-offline/blob/main-app-dev/muzik-offline/src-tauri/tauri.conf.json">tauri.config.json</a> and under the ```windows``` object, change the ```decorations``` property to ```true```
10. run
9. run
```
npm run tauri dev
```
11. You can encrypt your env file with:
10. You can encrypt your env file with:
```
openssl enc -aes-256-cbc -salt -pbkdf2 -in src-tauri/.env -out src-tauri/.env.enc -pass pass:{pass-key}
```

## Building
1. Clone the <a href="https://github.com/muzik-apps/muzik-offline/tree/releases">releases</a> branch. It is the most stable and ready to go branch
2. Before you create a build, you will have to embed any env variables into the rust code otherwise the application will panic if you try to run it. The env variables are only meant to be used in the development cycle.
4. If you want to create a production build, run
1. Clone the <a href="https://github.com/muzik-apps/muzik-offline/tree/releases">releases</a> branch. It is the most stable and "ready-to-go" branch
2. If you want to create a production build, run
```
npm run tauri build
```
5. If you want to create a <a href="https://tauri.app/v1/guides/debugging/application#using-the-inspector-in-production">debug production build</a>(one where you have access to devtools), run
3. If you want to create a <a href="https://tauri.app/v1/guides/debugging/application#using-the-inspector-in-production">debug production build</a>(one where you have access to devtools), run
```
npm run tauri build -- --debug
```

Please note that when you run ```npm run tauri dev```, ```npm run tauri build``` or ```npm run tauri build -- --debug``` for the first time, it may take a lengthy amount of minutes to compile everything. However this only occurs just on your first run. In subsequent runs, it will be faster.
> [!NOTE]
> Please note that when you run ```npm run tauri dev```, ```npm run tauri build``` or ```npm run tauri build -- --debug``` for the first time, it may take a lengthy amount of minutes to compile everything. However this only occurs just on your first run. In subsequent runs, it will be faster.
# Node modules used
1. <a href="https://www.npmjs.com/package/@tauri-apps/cli">tauri-apps/api</a>
1. <a href="https://www.npmjs.com/package/@tauri-apps/cli">tauri-apps</a>
2. <a href="https://dexie.org/">dexie</a>
3. <a href="https://www.framer.com/motion/">framer motion</a>
4. <a href="https://react.dev/">react and react-dom</a>
5. <a href="https://reactrouter.com/en/main">react-router-dom</a>
6. <a href="https://www.npmjs.com/package/react-viewport-list">react viewport list</a>
7. <a href="https://sass-lang.com/">sass</a>
8. <a href="https://docs.pmnd.rs/zustand/getting-started/introduction">zustand</a>
9. <a href="https://www.npmjs.com/package/react-loading-skeleton">react-loading-skeleton</a>

# Rust libraries used
1. <a href="https://crates.io/crates/tauri">tauri</a>
Expand All @@ -111,3 +111,14 @@ Please note that when you run ```npm run tauri dev```, ```npm run tauri build```
13. <a href="https://crates.io/crates/dirs">dirs</a>
14. <a href="https://crates.io/crates/discord-rich-presence">discord-rich-presence</a>
15. <a href="https://crates.io/crates/dotenv">dotenv</a>
16. <a href="https://crates.io/crates/souvlaki">souvlaki</a>
17. <a href="https://crates.io/crates/warp">warp</a>
18. <a href="https://crates.io/crates/tauri-plugin-shell">tauri-plugin-shell</a>
19. <a href="https://crates.io/crates/tauri-plugin-notification">tauri-plugin-notification</a>
20. <a href="https://crates.io/crates/tauri-plugin-dialog">tauri-plugin-dialog</a>
21. <a href="https://crates.io/crates/tauri-plugin-http">tauri-plugin-http</a>
22. <a href="https://crates.io/crates/tauri-plugin-os">tauri-plugin-os</a>
23. <a href="https://crates.io/crates/printpdf">printpdf</a>
24. <a href="https://crates.io/crates/tabled">tabled</a>
25. <a href="https://crates.io/crates/walkdir">walkdir</a>
26. <a href="https://crates.io/crates/futures">futures</a>
5 changes: 4 additions & 1 deletion muzik-offline/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ dist-ssr
*.ntvs*
*.njsproj
*.sln
*.sw?
*.sw?

/src-airplay-cast/__pycache__/
/src-airplay-cast/*.exe
4 changes: 2 additions & 2 deletions muzik-offline/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 muzik-offline/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "muzik-offline",
"private": true,
"version": "0.6.2",
"version": "0.7.0",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
72 changes: 71 additions & 1 deletion muzik-offline/src-tauri/Cargo.lock

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

4 changes: 3 additions & 1 deletion muzik-offline/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "muzik-offline"
version = "0.6.2"
version = "0.7.0"
description = "A desktop music player for listening to music offline."
authors = ["Michael"]
license = "MIT"
Expand Down Expand Up @@ -40,6 +40,8 @@ printpdf = "0.7.0"
tabled = "0.16.0"
walkdir = "2.5.0"
futures = "0.3.31"
rodio = "0.20.1"
trash = "5.2.0"

[dependencies.uuid]
version = "1.11.0"
Expand Down
45 changes: 25 additions & 20 deletions muzik-offline/src-tauri/src/app/setup.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::components::audio_manager::BackendStateManager;
use crate::components::audio_manager::AppAudioManager;
use crate::components::kira_audio_manager::KiraManager;
use crate::components::rodio_audio_manager::RodioManager;
use crate::database::db_api::{get_image_from_tree, get_null_cover_from_tree, get_thumbnail, get_wallpaper};
use crate::database::db_manager::DbManager;
use kira::manager::{backend::DefaultBackend, AudioManager, AudioManagerSettings};
Expand All @@ -8,23 +10,36 @@ use warp::{http::Uri, reply::Response, Filter, Reply};

use std::sync::{Arc, Mutex};
use tauri::async_runtime::{self, spawn};
use tauri::{AppHandle, Emitter, Manager};
use tauri::Manager;
use tokio::sync::mpsc;

use crate::music::media_control_api::{config_mca, event_handler};
use crate::utils::general_utils::get_random_port;

use super::setup_macos;

/// Initializes the BackendStateManager with required settings.
pub fn initialize_audio_manager() -> Arc<Mutex<BackendStateManager>> {
/// Initializes the kira audio manager with required settings.
pub fn initialise_kira_audio_manager() -> Arc<Mutex<KiraManager>> {
let audio_manager = AudioManager::<DefaultBackend>::new(AudioManagerSettings::default())
.expect("failed to initialize audio manager");

Arc::new(Mutex::new(BackendStateManager {
Arc::new(Mutex::new(KiraManager {
manager: audio_manager,
instance_handle: None,
volume: 0.0,
crossfade: false,
duration: None,
}))
}

/// Initializes the Rodio audio manager with required settings.
pub fn initialise_rodio_audio_manager() -> Arc<Mutex<RodioManager>> {
Arc::new(Mutex::new(RodioManager::new()))
}

/// Initializes the AppAudioManager with required settings.
pub fn initialize_audio_manager() -> Arc<Mutex<AppAudioManager>> {
// Create a Rodio device and get the output stream handle
Arc::new(Mutex::new(AppAudioManager {
controls: None,
cover_url: String::new(),
port: 0,
Expand All @@ -38,9 +53,10 @@ pub fn setup_app(app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error>>
mpsc::Receiver<MediaControlEvent>,
) = mpsc::channel(32);
setup_macos::setup_macos(app)?;
let shared_audio_manager = Arc::clone(&app.state::<Arc<Mutex<BackendStateManager>>>());
let shared_audio_manager = Arc::clone(&app.state::<Arc<Mutex<AppAudioManager>>>());
let shared_db_manager = Arc::clone(&app.state::<Arc<Mutex<DbManager>>>());
let window = app.handle().clone();

// setup audio manager

// Set up the image route
let cover_image_route = create_image_route_for_covers(shared_db_manager.clone());
Expand Down Expand Up @@ -83,14 +99,13 @@ pub fn setup_app(app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error>>
.controls = Some(controls);

// Handle media control events
let window = app.handle().clone();
spawn(async move {
while let Some(event) = rx.recv().await {
event_handler(&window, &event);
}
});

// Collect args from the command line
collect_args(app.handle());
Ok(())
}

Expand Down Expand Up @@ -229,14 +244,4 @@ pub fn setup_media_controls(
controls,
&format!("http://localhost:{}/covers/NULL_COVER_NULL", port).to_owned(),
);
}

/// Collect args from the command line and return them as a vector of strings.
pub fn collect_args(app: &AppHandle) {
let args: Vec<String> = std::env::args().collect();
if args.len() > 1 {
let audio_file_path = &args[1];
app.emit("loadSong", audio_file_path)
.expect("failed to emit loadSong");
}
}
Loading

0 comments on commit b3376cf

Please sign in to comment.