[GH-ISSUE #374] Non-blocking Player::load #248

Closed
opened 2026-02-27 19:29:38 +03:00 by kerem · 3 comments
Owner

Originally created by @snaiperskaya96 on GitHub (Sep 22, 2019).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/374

Hiya,

in first place i'm sorry if i'm going to say some random oddities, i'm quite new to rust.
I've been trying to have Player:load running in the background or in such a way i can continue execute my code and interact with the player later on but i've been out of luck so far.

Could you please give me some advises on how to proceed, my code is currently based on the example in examples/play.rs

Is there any alternative to this?

    core.run(player.load(track, true, 0)).unwrap();

Thank youuu

Originally created by @snaiperskaya96 on GitHub (Sep 22, 2019). Original GitHub issue: https://github.com/librespot-org/librespot/issues/374 Hiya, in first place i'm sorry if i'm going to say some random oddities, i'm quite new to rust. I've been trying to have Player:load running in the background or in such a way i can continue execute my code and interact with the player later on but i've been out of luck so far. Could you please give me some advises on how to proceed, my code is currently based on the example in examples/play.rs Is there any alternative to this? ```rust core.run(player.load(track, true, 0)).unwrap(); ``` Thank youuu
kerem 2026-02-27 19:29:38 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@snaiperskaya96 commented on GitHub (Sep 22, 2019):

As a follow up i can do stuff like calling player.load(track, true, 0) and keep polling on it but then it would get stuck at Player::load_track, waiting for Tracket::get() forever 🤷‍♂

<!-- gh-comment-id:533891917 --> @snaiperskaya96 commented on GitHub (Sep 22, 2019): As a follow up i can do stuff like calling `player.load(track, true, 0)` and keep polling on it but then it would get stuck at Player::load_track, waiting for Tracket::get() forever 🤷‍♂
Author
Owner

@HEnquist commented on GitHub (Sep 24, 2019):

You can maybe run it in a separate thread with
futures_cpupool::CpuPool see the first part of the answer here:
https://stackoverflow.com/questions/41932137/what-is-the-best-approach-to-encapsulate-blocking-i-o-in-future-rs

Something like this (not proper code, just to give an idea):

let pool = CpuPool::new(8);
let a = pool.spawn_fn(|| {
        player.load(track, true, 0);
        future::ok::<_, ()>(player)
});
core.run(a).unwrap();
<!-- gh-comment-id:534681290 --> @HEnquist commented on GitHub (Sep 24, 2019): You can maybe run it in a separate thread with futures_cpupool::CpuPool see the first part of the answer here: https://stackoverflow.com/questions/41932137/what-is-the-best-approach-to-encapsulate-blocking-i-o-in-future-rs Something like this (not proper code, just to give an idea): ``` let pool = CpuPool::new(8); let a = pool.spawn_fn(|| { player.load(track, true, 0); future::ok::<_, ()>(player) }); core.run(a).unwrap(); ```
Author
Owner

@HEnquist commented on GitHub (Feb 9, 2020):

Should we close this? It's not really an issue and there's no activity since September..

<!-- gh-comment-id:583883132 --> @HEnquist commented on GitHub (Feb 9, 2020): Should we close this? It's not really an issue and there's no activity since September..
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot#248
No description provided.