pub struct AsyncSCContentSharingPicker;Expand description
Async wrapper for SCContentSharingPicker (macOS 14.0+)
Provides async methods to show the system content sharing picker UI. Executor-agnostic - works with any async runtime.
§Examples
use screencapturekit::async_api::AsyncSCContentSharingPicker;
use screencapturekit::content_sharing_picker::*;
async fn pick_content() {
let config = SCContentSharingPickerConfiguration::new();
match AsyncSCContentSharingPicker::show(&config).await {
SCPickerOutcome::Picked(result) => {
let (width, height) = result.pixel_size();
let filter = result.filter();
println!("Selected content: {}x{}", width, height);
}
SCPickerOutcome::Cancelled => println!("User cancelled"),
SCPickerOutcome::Error(e) => eprintln!("Error: {}", e),
}
}Implementations§
Source§impl AsyncSCContentSharingPicker
impl AsyncSCContentSharingPicker
Sourcepub fn show(config: &SCContentSharingPickerConfiguration) -> AsyncPickerFuture ⓘ
pub fn show(config: &SCContentSharingPickerConfiguration) -> AsyncPickerFuture ⓘ
Show the picker UI asynchronously and return SCPickerResult with filter and metadata
This is the main API - use when you need content dimensions or want to build custom filters. The picker UI will be shown on the main thread, and the future will resolve when the user makes a selection or cancels.
§Example
use screencapturekit::async_api::AsyncSCContentSharingPicker;
use screencapturekit::content_sharing_picker::*;
async fn example() {
let config = SCContentSharingPickerConfiguration::new();
if let SCPickerOutcome::Picked(result) = AsyncSCContentSharingPicker::show(&config).await {
let (width, height) = result.pixel_size();
let filter = result.filter();
}
}Sourcepub fn show_filter(
config: &SCContentSharingPickerConfiguration,
) -> AsyncPickerFilterFuture ⓘ
pub fn show_filter( config: &SCContentSharingPickerConfiguration, ) -> AsyncPickerFilterFuture ⓘ
Show the picker UI asynchronously and return an SCContentFilter directly
This is the simple API - use when you just need the filter without metadata.
§Example
use screencapturekit::async_api::AsyncSCContentSharingPicker;
use screencapturekit::content_sharing_picker::*;
async fn example() {
let config = SCContentSharingPickerConfiguration::new();
if let SCPickerFilterOutcome::Filter(filter) = AsyncSCContentSharingPicker::show_filter(&config).await {
// Use filter with SCStream
}
}Sourcepub fn show_for_stream(
config: &SCContentSharingPickerConfiguration,
stream: &SCStream,
) -> AsyncPickerFuture ⓘ
pub fn show_for_stream( config: &SCContentSharingPickerConfiguration, stream: &SCStream, ) -> AsyncPickerFuture ⓘ
Show the picker UI for an existing stream to change source while capturing
Use this when you have an active SCStream and want to let the user
select a new content source. The result can be used with stream.update_content_filter().
§Example
use screencapturekit::async_api::AsyncSCContentSharingPicker;
use screencapturekit::content_sharing_picker::*;
use screencapturekit::stream::SCStream;
use screencapturekit::stream::configuration::SCStreamConfiguration;
use screencapturekit::stream::content_filter::SCContentFilter;
use screencapturekit::shareable_content::SCShareableContent;
async fn example() -> Option<()> {
let content = SCShareableContent::get().ok()?;
let displays = content.displays();
let display = displays.first()?;
let filter = SCContentFilter::create().with_display(display).with_excluding_windows(&[]).build();
let stream_config = SCStreamConfiguration::new();
let stream = SCStream::new(&filter, &stream_config);
// When stream is active and user wants to change source
let config = SCContentSharingPickerConfiguration::new();
if let SCPickerOutcome::Picked(result) = AsyncSCContentSharingPicker::show_for_stream(&config, &stream).await {
// Use result.filter() with stream.update_content_filter()
let _ = result.filter();
}
Some(())
}Trait Implementations§
Source§impl Clone for AsyncSCContentSharingPicker
impl Clone for AsyncSCContentSharingPicker
Source§fn clone(&self) -> AsyncSCContentSharingPicker
fn clone(&self) -> AsyncSCContentSharingPicker
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more