mirror of
https://github.com/Dangoware/dango-music-player.git
synced 2025-04-19 01:52:53 -05:00
Updated the discord thing again. this time it's not repeating the position_tx reciever every time
This commit is contained in:
parent
7a9ee5c22a
commit
41c7820dfb
1 changed files with 8 additions and 15 deletions
|
@ -198,7 +198,6 @@ fn discord_rpc(client_id: u64, song_tx: Receiver<Song>, state_tx: Receiver<Prism
|
||||||
.duration_since(UNIX_EPOCH)
|
.duration_since(UNIX_EPOCH)
|
||||||
.expect("Time went backwards?")
|
.expect("Time went backwards?")
|
||||||
.as_secs();
|
.as_secs();
|
||||||
let mut tick = Instant::now();
|
|
||||||
|
|
||||||
DC_ACTIVE.store(true, Ordering::Relaxed);
|
DC_ACTIVE.store(true, Ordering::Relaxed);
|
||||||
|
|
||||||
|
@ -218,23 +217,17 @@ fn discord_rpc(client_id: u64, song_tx: Receiver<Song>, state_tx: Receiver<Prism
|
||||||
now = SystemTime::now().duration_since(UNIX_EPOCH).expect("Time went backwards?").as_secs();
|
now = SystemTime::now().duration_since(UNIX_EPOCH).expect("Time went backwards?").as_secs();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
recv(position_tx) -> pos => {
|
|
||||||
let elapsed = tick.elapsed().as_secs();
|
|
||||||
if elapsed >= 5 {
|
|
||||||
if let Ok(Some(pos)) = pos {
|
|
||||||
// set back the start position to where it would be if it hadn't been paused / seeked
|
|
||||||
now = SystemTime::now()
|
|
||||||
.duration_since(UNIX_EPOCH)
|
|
||||||
.expect("Time went backwards?")
|
|
||||||
.as_secs() - u64::try_from(pos.num_seconds()).unwrap() - 1;
|
|
||||||
tick = Instant::now();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
default(Duration::from_millis(1000)) => {}
|
default(Duration::from_millis(1000)) => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Ok(Some(pos)) = position_tx.recv_timeout(Duration::from_millis(100)) {
|
||||||
|
// set back the start position to where it would be if it hadn't been paused / seeked
|
||||||
|
now = SystemTime::now()
|
||||||
|
.duration_since(UNIX_EPOCH)
|
||||||
|
.expect("Time went backwards?")
|
||||||
|
.as_secs() - u64::try_from(pos.num_seconds()).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
client
|
client
|
||||||
.set_activity(|activity| {
|
.set_activity(|activity| {
|
||||||
let activity = activity
|
let activity = activity
|
||||||
|
|
Loading…
Reference in a new issue