Skip to main content

Module content_sharing_picker

Module content_sharing_picker 

Source
Expand description

SCContentSharingPicker - UI for selecting content to share

Available on macOS 14.0+. Provides a system UI for users to select displays, windows, or applications to share.

§When to Use

Use the content sharing picker when:

  • You want users to choose what to capture via a native macOS UI
  • You need consistent UX with other screen sharing apps
  • You want to avoid manually listing and presenting content options

§APIs

MethodReturnsUse Case
SCContentSharingPicker::show()callback with SCPickerOutcomeGet filter + metadata (dimensions, picked content)
SCContentSharingPicker::show_filter()callback with SCPickerFilterOutcomeJust get the filter

For async/await, use AsyncSCContentSharingPicker from the optional async_api module.

§Examples

§Callback API: Get filter with metadata

use screencapturekit::content_sharing_picker::*;
use screencapturekit::prelude::*;

let config = SCContentSharingPickerConfiguration::new().expect("create picker configuration");
SCContentSharingPicker::show(&config, |outcome| {
    match outcome {
        SCPickerOutcome::Picked(result) => {
            let (width, height) = result.pixel_size();
            let filter = result.filter();
            println!("Selected content: {}x{}", width, height);
            // Create stream with the filter...
        }
        SCPickerOutcome::Cancelled => println!("Cancelled"),
        SCPickerOutcome::Error(e) => eprintln!("Error: {}", e),
    }
});

§Async API

use screencapturekit::async_api::AsyncSCContentSharingPicker;
use screencapturekit::content_sharing_picker::*;

async fn example() {
    let config = SCContentSharingPickerConfiguration::new().expect("create picker configuration");
    if let SCPickerOutcome::Picked(result) = AsyncSCContentSharingPicker::show(&config).await {
        let (width, height) = result.pixel_size();
        let filter = result.filter();
        println!("Selected: {}x{}", width, height);
    }
}

§Configure Picker Modes

use screencapturekit::content_sharing_picker::*;

let mut config = SCContentSharingPickerConfiguration::new().expect("create picker configuration");
// Only allow single display selection
config.set_allowed_picker_modes(&[SCContentSharingPickerMode::SingleDisplay]);
// Exclude specific apps from the picker
config.set_excluded_bundle_ids(&["com.apple.finder", "com.apple.dock"]).expect("bundle IDs have no NUL byte");

Re-exports§

pub use crate::stream::StreamIdentity;

Structs§

SCContentSharingPicker
System UI for selecting content to share
SCContentSharingPickerConfiguration
Configuration for the content sharing picker
SCPickerResult
Result from the main show() API - contains filter and content metadata
SCPickerSubscription
Handle representing a live repeating-observer registration.

Enums§

SCContentSharingPickerMode
Picker mode determines what content types can be selected
SCPickedSource
Represents the type of content selected in the picker
SCPickerConfigurationError
Error returned by SCContentSharingPicker operations.
SCPickerEvent
A single event delivered to a repeating observer registered with SCContentSharingPicker::add_observer.
SCPickerFilterOutcome
Result from the simple show_filter() API
SCPickerOutcome
Outcome from the main show() API