pub trait SCStreamDelegateTrait: Send {
// Provided methods
fn output_video_effect_did_start_for_stream(&self) { ... }
fn output_video_effect_did_stop_for_stream(&self) { ... }
fn stream_did_become_active(&self) { ... }
fn stream_did_become_inactive(&self) { ... }
fn did_stop_with_error(&self, _error: SCError) { ... }
fn stream_did_stop(&self, _error: Option<String>) { ... }
}Expand description
Trait for handling stream lifecycle events
Implement this trait to receive notifications about stream state changes, errors, and video effects.
§Examples
§Using a struct
use screencapturekit::stream::delegate_trait::SCStreamDelegateTrait;
use screencapturekit::error::SCError;
struct MyDelegate;
impl SCStreamDelegateTrait for MyDelegate {
fn stream_did_stop(&self, error: Option<String>) {
if let Some(err) = error {
eprintln!("Stream stopped with error: {}", err);
} else {
println!("Stream stopped normally");
}
}
fn did_stop_with_error(&self, error: SCError) {
eprintln!("Stream error: {}", error);
}
}§Using closures
Use StreamCallbacks to create a delegate from closures:
use screencapturekit::prelude::*;
use screencapturekit::stream::delegate_trait::StreamCallbacks;
let delegate = StreamCallbacks::new()
.on_stop(|error| {
if let Some(e) = error {
eprintln!("Stream stopped with error: {}", e);
}
})
.on_error(|error| eprintln!("Error: {}", error));
let stream = SCStream::new_with_delegate(&filter, &config, delegate);Provided Methods§
Sourcefn output_video_effect_did_start_for_stream(&self)
fn output_video_effect_did_start_for_stream(&self)
Called when video effects start (macOS 14.0+)
Notifies when the stream’s overlay video effect (presenter overlay) has started.
Sourcefn output_video_effect_did_stop_for_stream(&self)
fn output_video_effect_did_stop_for_stream(&self)
Called when video effects stop (macOS 14.0+)
Notifies when the stream’s overlay video effect (presenter overlay) has stopped.
Sourcefn stream_did_become_active(&self)
fn stream_did_become_active(&self)
Called when the stream becomes active (macOS 15.2+)
Notifies the first time any window that was being shared in the stream
is re-opened after all the windows being shared were closed.
When all the windows being shared are closed, the client will receive
stream_did_become_inactive.
Sourcefn stream_did_become_inactive(&self)
fn stream_did_become_inactive(&self)
Called when the stream becomes inactive (macOS 15.2+)
Notifies when all the windows that are currently being shared are exited. This callback occurs for all content filter types.
Sourcefn did_stop_with_error(&self, _error: SCError)
fn did_stop_with_error(&self, _error: SCError)
Called when stream stops with an error
Sourcefn stream_did_stop(&self, _error: Option<String>)
fn stream_did_stop(&self, _error: Option<String>)
Called when stream stops
§Parameters
error: Optional error message if the stream stopped due to an error