We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Thanks to neon, I can use Rodio in nodejs. When using 0.11.0, it can play audio in background and do not block the process.
0.11.0
use neon::prelude::*; use std::{fs::File, io::BufReader}; fn load(mut cx: FunctionContext) -> JsResult<JsUndefined> { let url = cx.argument::<JsString>(0)?.value(); let device = rodio::default_output_device().unwrap(); let sink = rodio::Sink::new(&device); let file = File::open(url).unwrap(); sink.append(rodio::Decoder::new(BufReader::new(file)).unwrap()); Ok(cx.undefined()) } register_module!(mut cx, { cx.export_function("load", load) });
But when using git version, there is no sound unless add sleep_until_end. However, the main thread is blocked.
sleep_until_end
use neon::prelude::*; use std::{fs::File, io::BufReader}; fn load(mut cx: FunctionContext) -> JsResult<JsUndefined> { let url = cx.argument::<JsString>(0)?.value(); let (_stream, handle) = rodio::OutputStream::try_default().unwrap(); let sink = rodio::Sink::try_new(&handle).unwrap(); let file = File::open(url).unwrap(); sink.append(rodio::Decoder::new(BufReader::new(file)).unwrap()); // play sound only if uncomment the next line // sink.sleep_until_end(); Ok(cx.undefined()) } register_module!(mut cx, { cx.export_function("load", load) });
Therefore, my question is whether there is a way to play sound without blocking main thread.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Thanks to neon, I can use Rodio in nodejs.
When using
0.11.0
, it can play audio in background and do not block the process.But when using git version, there is no sound unless add
sleep_until_end
. However, the main thread is blocked.Therefore, my question is whether there is a way to play sound without blocking main thread.
The text was updated successfully, but these errors were encountered: