Skip to content

Commit

Permalink
logo, discordRPC
Browse files Browse the repository at this point in the history
  • Loading branch information
fucksophie committed Jun 5, 2023
1 parent fc067aa commit b0b85c0
Show file tree
Hide file tree
Showing 21 changed files with 290 additions and 71 deletions.
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
# musicplayer2-tauri

<center>
<img src="assets/logo/logo.png">
</center>

An semi-complciated music player written in React and Tailwind, using Tauri for cross-platform.

Supports:
1. Full LastFM compatability
2. **ONLY** Subsonic is supported. Local file support might come eventually, but don't count on it.
3. Most of Subsonic API.

4. DiscordRPC support

## To build
Just run `npm i`, then `npm run tauri dev`. You must have rust & cargo installed, webkitGTK and whatnot else.
Check the [tauri V2 docs](https://next--tauri.netlify.app/next/guides/building/) for more information on building.
Check the [tauri V2 docs](https://next--tauri.netlify.app/next/guides/building/) for more information on building.

## Screenshots
### Pages
![1st screenshot, showing login](assets/screenshots/1.png)
![2nd screenshot, showing songs](assets/screenshots/2.png)
![3rd screenshot, showing integrations](assets/screenshots/3.png)
### Appearance
![4th screenshot, showing appearance selections](assets/screenshots/4.png)
#### Themes
![5th screenshot, showing light-red theme](assets/screenshots/5.png)
![6th screenshot, showing dark-slate](assets/screenshots/6.png)
Binary file added assets/logo/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 77 additions & 0 deletions assets/logo/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/logo/logo.xcf
Binary file not shown.
Binary file added assets/logo/white-bg-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/oa-card/oa-card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/oa-card/oa-card.xcf
Binary file not shown.
Binary file added assets/screenshots/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 75 additions & 2 deletions src-tauri/Cargo.lock

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

4 changes: 2 additions & 2 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ license = ""
repository = ""
edition = "2021"

[lib]
crate-type = ["staticlib", "cdylib", "rlib"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -21,6 +19,8 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
log = "^0.4"
discord-presence = "0.5"
once_cell = "1.17.2"

[features]
# this feature is used for production builds or when `devPath` points to the filesystem
Expand Down
50 changes: 0 additions & 50 deletions src-tauri/src/lib.rs

This file was deleted.

79 changes: 71 additions & 8 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,71 @@
#![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
use musicplayer2_tauri::AppBuilder;
pub fn main() {
AppBuilder::new().run();
}
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

use discord_presence::{Client, Event};
use once_cell::sync::Lazy;
use tauri_plugin_log::{TargetKind, Target};

// TODO: Eventually - when I get better at Rust I'm going to remove these static mutables
static mut CLIENT: Lazy<Client> = Lazy::new(|| Client::new(988215000676073532));
static mut STARTED_CLIENT: bool = false;

#[cfg(not(mobile))]
#[tauri::command]
fn start_discord_rpc() {
println!("[RUST] DiscordRPC requested to be started by JS.");

unsafe {
if STARTED_CLIENT {
println!("[RUST] Client was already started!");
return;
}
STARTED_CLIENT = true;
_ = CLIENT.start();

CLIENT.block_until_event(Event::Ready).unwrap();
}

println!("[RUST] DiscordRPC connected to Client.")
}

#[cfg(not(mobile))]
#[tauri::command]
fn clear_actvitiy() {
unsafe {
if STARTED_CLIENT {
CLIENT.clear_activity().expect("failed to clear activity");
}
}
}

#[cfg(not(mobile))]
#[tauri::command]
fn set_discord_rpc(state: String, details: String, image: String) {
println!("[RUST] Attempting to set DiscordRPC state to \"{}\" and details to \"{}\" and to \"{}\".", state, details, image);
if state.is_empty() { return; }
if details.is_empty() { return; }
if image.is_empty() { return; }

unsafe {
CLIENT.set_activity(|act|
act
.state(state)
.details(details)
.assets(|aset|
aset.large_image(image).large_text("musicplayer2")
))
.expect("[RUST] Failed to set activity");
}
println!("[RUST] Succeeded!")
}

fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_log::Builder::default().targets([
Target::new(TargetKind::Stdout),
Target::new(TargetKind::Webview),
]).build())
.invoke_handler(tauri::generate_handler![set_discord_rpc, start_discord_rpc, clear_actvitiy])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
4 changes: 0 additions & 4 deletions src-tauri/src/mobile.rs

This file was deleted.

Loading

0 comments on commit b0b85c0

Please sign in to comment.