fix(queue): tracks not ending sometimes
This commit is contained in:
@@ -49,13 +49,16 @@ impl AudioPlayer {
|
|||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
loop {
|
loop {
|
||||||
if let Some(current_track) = current_track.lock().await.as_mut() {
|
if let Some(current_track) = current_track.lock().await.as_mut() {
|
||||||
if current_track.duration as u128 <= sink.lock().await.get_pos().as_millis()
|
let sink = sink.lock().await;
|
||||||
|
if sink.empty()
|
||||||
|
|| current_track.duration as u128 <= sink.get_pos().as_millis()
|
||||||
{
|
{
|
||||||
if let Err(_) = tx.send(queue.lock().await.pop_front()).await {
|
if let Err(_) = tx.send(queue.lock().await.pop_front()).await {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tokio::time::sleep(Self::WATCH_SLEEP_TIME).await;
|
tokio::time::sleep(Self::WATCH_SLEEP_TIME).await;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user