Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read from STDIN while playing a track #104

Closed
sashahilton00 opened this issue Jan 29, 2018 · 1 comment
Closed

read from STDIN while playing a track #104

sashahilton00 opened this issue Jan 29, 2018 · 1 comment

Comments

@sashahilton00
Copy link
Member

Issue by wijnanb
Monday Jan 22, 2018 at 21:28 GMT
Originally opened as plietar/librespot#274


I am trying to adapt the play.rs example to make it able to be controlled via STDIN.
As my experience with Rust is very minimal i am struggling with handling non-blocking IO.

My code is as follows:

loop {
        println!("Waiting for input");
        let stdin = std::io::stdin();
        let l = stdin.lock().lines().next().unwrap().unwrap();
        println!("Received input: {}", line);

        let next_track = SpotifyId::from_base62(&line);

        println!("Playing next track... {}", line);
        core.run(player.load(next_track, true, 0)).unwrap();
        // execution on this thread is blocked?
    }

How can we interrupt the execution of `core.run()?

I have been reading on core::handle and core::remote but since I am used to node.js I am feeling a bit lost here ... ;-)

Can someone point me in the right direction?

@ComlOnline
Copy link
Contributor

Hey @wijnanb, Please see #105 for more information on controlling from the command line. I don't think that this is something that we would be wanting for librespot and it's not meant to be controlled directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants