9 Commits
Author SHA1 Message Date
nicknase27 1789e7b552 Cache Cargo dependencies
Build / build (push) Successful in 3m48s
2026-07-26 11:40:39 +02:00
nicknase27 ff6bc6ab4c workflow fix?
Build / build (push) Successful in 2m56s
2026-07-26 11:25:16 +02:00
nicknase27 68bc9f6a8a readme
Build / build (push) Failing after 15s
2026-07-26 11:23:08 +02:00
nicknase27 e4efa28647 Add release uploads to workflow 2026-07-26 11:21:06 +02:00
nicknase27 f681982fe5 add Readme?
Build / build (push) Canceled after 33s
2026-07-26 11:13:58 +02:00
nicknase27 3c28d3b09c remove readme
Build / build (push) Successful in 2m51s
2026-07-26 11:12:27 +02:00
nicknase27 f51fd27c09 Test 2026-07-26 11:10:37 +02:00
nicknase27 cc687eb159 Gitea workflow? 2026-07-26 11:09:16 +02:00
nicknase27 afe2e6d375 Release 2026-07-26 11:03:56 +02:00
3 changed files with 155 additions and 127 deletions
+58
View File
@@ -0,0 +1,58 @@
name: Build
on:
push:
tags:
- "v*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: |
x86_64-unknown-linux-gnu
x86_64-pc-windows-gnu
- uses: https://gitea.com/actions/cache@v6
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-${{ runner.os }}-
- name: Install dependencies
run: |
apt-get update
apt-get install -y \
pkg-config \
libasound2-dev \
gcc-mingw-w64-x86-64
- name: Build Linux
run: cargo build --release --target x86_64-unknown-linux-gnu
- name: Build Windows
env:
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER: x86_64-w64-mingw32-gcc
run: cargo build --release --target x86_64-pc-windows-gnu
- name: Collect artifacts
run: |
mkdir artifacts
cp target/x86_64-unknown-linux-gnu/release/ncmprs artifacts/ncmprs
cp target/x86_64-pc-windows-gnu/release/ncmprs.exe artifacts/ncmprs.exe
- name: Create Release
uses: akkuman/gitea-release-action@v1
with:
files: |
artifacts/ncmprs
artifacts/ncmprs.exe
-45
View File
@@ -1,45 +0,0 @@
name: Build and Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build:
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
binary: ncmprs
- os: windows-latest
target: x86_64-pc-windows-msvc
binary: ncmprs.exe
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libasound2-dev pkg-config
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Upload to Release
uses: softprops/action-gh-release@v2
with:
files: target/${{ matrix.target }}/release/${{ matrix.binary }}
+97 -82
View File
@@ -187,50 +187,6 @@ impl App {
Ok(())
}
/*
pub fn play(&mut self) {
let file = File::open(self.songs[self.list_state.selected().expect("None")].clone()).unwrap();
let source = Decoder::new(BufReader::new(file)).unwrap();
if self.player.empty() {
self.player.append(source);
} else {
self.player.stop();
self.player.append(source);
}
}
*/
pub fn play(&mut self) {
if !self.queue.is_empty() {
for _i in 0..self.queue.len() {
let file = File::open(
self.library.songs[*self.queue.front().expect("None")]
.path
.clone(),
)
.unwrap();
let source = Decoder::new(BufReader::new(file)).unwrap();
self.queue.pop_front();
self.player.append(source);
}
} else {
let file = File::open(
self.library.songs[self.artist_state.selected().expect("None")]
.path
.clone(),
)
.unwrap();
let source = Decoder::new(BufReader::new(file)).unwrap();
if self.player.empty() {
self.player.append(source);
} else {
self.player.stop();
self.player.append(source);
}
}
}
pub fn play_song(&mut self, index: usize) {
let song_indexes = self.current_selected_song();
let song_index = song_indexes[index];
@@ -256,52 +212,72 @@ impl App {
song_indexes.to_owned()
}
// pub fn play_pause(&mut self) {
// if self.current_song().is_some() {
// let song = &self.library.songs[self.current_song.unwrap()];
// let duration = song.duration.unwrap_or(1.0) as i64;
// let artist = &song.artist;
// if let Some(client) = self.discord_client.as_mut() {
// if !self.player.is_paused() {
// self.player.pause();
// self.paused_at = self.player.get_pos().as_secs() as i64;
//
// let asset = Assets::new();
// let activity = activity::Activity::new()
// .name("NCMPRS")
// .details(song.title.clone())
// .state("Paused")
// .activity_type(activity::ActivityType::Listening)
// .assets(asset.large_image("https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/navidrome.png"));
// let _ = client.set_activity(activity);
// } else if self.player.is_paused() {
// self.player.play();
// let now = SystemTime::now()
// .duration_since(UNIX_EPOCH)
// .unwrap()
// .as_secs() as i64;
// let timestamps = Timestamps::new()
// .start(now - self.paused_at)
// .end((now - self.paused_at) + duration);
// let asset = Assets::new();
//
// let payload = activity::Activity::new()
// .name("NCMPRS")
// .details(song.title.clone())
// .state(artist)
// .activity_type(activity::ActivityType::Listening)
// .timestamps(timestamps)
// .assets(asset.large_image("https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/navidrome.png"));
//
// let _ = client.set_activity(payload);
// }
// }
// }
// }
pub fn play_pause(&mut self) {
if self.current_song().is_some() {
let song = &self.library.songs[self.current_song.unwrap()];
let duration = song.duration.unwrap_or(1.0) as i64;
let artist = &song.artist;
if let Some(client) = self.discord_client.as_mut() {
if !self.player.is_paused() {
self.player.pause();
self.paused_at = self.player.get_pos().as_secs() as i64;
let song_idx = match self.current_song {
Some(idx) => idx,
None => return,
};
let asset = Assets::new();
let activity = activity::Activity::new()
.name("NCMPRS")
.details(song.title.clone())
.state("Paused")
.activity_type(activity::ActivityType::Listening)
.assets(asset.large_image("https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/navidrome.png"));
let _ = client.set_activity(activity);
} else if self.player.is_paused() {
self.player.play();
let now = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs() as i64;
let timestamps = Timestamps::new()
.start(now - self.paused_at)
.end((now - self.paused_at) + duration);
let asset = Assets::new();
let song = &self.library.songs[song_idx];
let duration = song.duration.unwrap_or(1.0) as i64;
let title = song.title.clone();
let artist = song.artist.clone();
let payload = activity::Activity::new()
.name("NCMPRS")
.details(song.title.clone())
.state(artist)
.activity_type(activity::ActivityType::Listening)
.timestamps(timestamps)
.assets(asset.large_image("https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/navidrome.png"));
let _ = client.set_activity(payload);
}
}
if !self.player.is_paused() {
self.player.pause();
self.paused_at = self.player.get_pos().as_secs() as i64;
self.update_discord_rpc(true, title, artist, duration);
} else {
self.player.play();
self.update_discord_rpc(false, title, artist, duration);
}
}
pub fn inc_volume(&mut self) {
let vol = self.player.volume();
//self.player.set_volume(self.player.volume() + 0.1);
if vol >= 1.0 {
self.player.set_volume(1.0);
} else {
@@ -398,6 +374,45 @@ impl App {
}
}
fn update_discord_rpc(
&mut self,
is_paused: bool,
title: String,
artist: String,
duration: i64,
) {
let client = match self.discord_client.as_mut() {
Some(c) => c,
None => return,
};
let mut activity = activity::Activity::new()
.name("NCMPRS")
.details(title)
.activity_type(activity::ActivityType::Listening)
.assets(Assets::new().large_image(
"https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/navidrome.png",
));
if is_paused {
activity = activity.state("Paused");
} else {
let now = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs() as i64;
let start_time = now - self.paused_at;
activity = activity.state(artist).timestamps(
Timestamps::new()
.start(start_time)
.end(start_time + duration),
);
}
let _ = client.set_activity(activity);
}
/// Handles the tick event of the terminal.
///
/// The tick event is where you can update the state of your application with any logic that