Skip to content

Is there a way to use screen capture kit in sync code? #26

Answered by Kree0
Kree0 asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks, I use std::sync::mpsc::channel(), it works well for me:

        let (tx, rx) = std::sync::mpsc::channel();
        sc::ShareableContent::current_with_ch(move |a, b| {
            let mut res = Result::Err(BackendSpecificError {
                description: "Failed to get current shareable content".to_string(),
            });
            if let Some(err) = b {
                res = Result::Err(BackendSpecificError {
                    description: format!("{err}"),
                });
            }
            if let Some(sc) = a {
                res = Result::Ok(sc.retained());
            }
            tx.send(res).unwrap();
        });
        let sc_shareable_content = rx.recv(

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@Kree0
Comment options

Answer selected by yury
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants