avplayer
Safe Rust bindings for Apple's AVFoundation playback stack on macOS: AVPlayer, AVPlayerItem, AVPlayerLayer, AVQueuePlayer, AVPlayerLooper, AVAsset, AVURLAsset, and AVAssetReader.
Status:
0.3.0adds the Tier-1async_apimodule (feature-gated behindasync) wrapping AVFoundation'sasync throwsand completion-handler APIs as executor-agnostic RustFutures.0.2.2brought the crate to 100 % coverage of the audited macOS playback surface. SeeCOVERAGE.md.
Quick start
use *;
Async API
Enable the async Cargo feature for executor-agnostic Future wrappers around
AVFoundation's async throws and completion-handler APIs:
= { = "0.3", = ["async"] }
use ;
| Type | API wrapped |
|---|---|
async_api::AsyncAsset |
AVAsset.load(...), loadTracks(withMediaType:), loadTrack(withTrackID:) |
async_api::AsyncPlayerItem |
AVPlayerItem.seek(to:completionHandler:) |
async_api::AsyncPlayer |
AVPlayer.seek(to:completionHandler:), preroll(atRate:completionHandler:) |
KVO / notification streams (multi-fire) belong to a Tier-2 pattern and are not included in this module.
Highlights
AVAsset/AVURLAsset: async key loading, URL inspection, metadata, track enumeration, andUrlAssetOptions.AVPlayer: play/pause/rate/seek, volume + mute, action-at-item-end, time-control/waiting-state inspection, time observers, rate-change observation, HDR/background/network policy access, and media-selection criteria application.AVPlayerItem: observation callbacks (including time-jumped / failed-to-end / live-offset changes), buffering/bit-rate/resolution preferences, variant preferences, protected-content authorization status, custom compositor info, outputs, and per-item logs.AVPlayerLayer: player attachment, video gravity, video rect inspection, and displayed pixel-buffer access.AVQueuePlayer/AVPlayerLooper: queue mutation, current-item inspection, loop configuration, and loop-state reporting.AVPlayerItemOutput,AVPlayerItemVideoOutput,AVPlayerItemMetadataOutput, andAVPlayerItemLegibleOutput: attach/detach, base-output timing/suppression helpers, delegate observation, and text-styling/output configuration helpers.AVPlayerItemTrack,AVPlayerItemAccessLog,AVPlayerItemErrorLog, andAVPlayerMediaSelectionCriteriawrappers.AVAssetReader,AssetReaderTrackOutput,AssetReaderAudioMixOutput, andAssetReaderVideoCompositionOutputremain available for frame/sample extraction.
Examples
Every requested subsystem area now has a numbered example:
01_smoke_surface02_avasset03_avurlasset04_avplayer05_avplayer_item06_avplayer_layer07_avqueue_player08_avplayer_looper09_avplayer_item_access_log10_avplayer_item_error_log11_avplayer_item_metadata_output12_avplayer_item_video_output13_avplayer_item_legible_output14_avplayer_item_track15_avplayer_media_selection_criteria
Run any example with:
Examples write synthesized media into target/example-artifacts/ and avoid /tmp.
Notes
AVPlayerItemTrackmaterialization is media- and readiness-dependent. On synthesizedAIFFs,AVFoundationmay legitimately report zeroAVPlayerItemTrackinstances until it fully prepares the item.- The current macOS SDK used for this release does not expose
AVPlayerItem.externalMetadata, soPlayerItem::metadata()continues to surface the underlying asset metadata.
License
Licensed under either of Apache-2.0 or MIT at your option.