mediaplayer-rs
Safe Rust bindings for Apple's MediaPlayer.framework on macOS.
Status: v0.3.0 adds a Tier-2 async stream module (
asyncfeature) wrapping six notification / delegate / command-target surfaces as executor-agnosticBoundedAsyncStream<T>event streams. v0.2.0 covers the macOS-available now-playing, remote-command, language-option, and artwork APIs, and exposes explicit macOS-unavailable wrappers for the iOS-onlyMPMediaLibrary,MPMediaQuery,MPMusicPlayer,MPMediaItem,MPMediaItemCollection,MPMediaPlaylist,MPVolumeView,MPSystemMusicPlayer, andMPPlayableContentDataSourceareas.
Async streams (async feature)
Enable with features = ["async"]:
= { = "0.3", = ["async"] }
| Stream type | Apple surface |
|---|---|
NowPlayingItemChangeStream |
MPMusicPlayerControllerNowPlayingItemDidChangeNotification |
PlaybackStateChangeStream |
MPMusicPlayerControllerPlaybackStateDidChangeNotification |
VolumeChangeStream |
MPMusicPlayerControllerVolumeDidChangeNotification |
MediaLibraryChangeStream |
MPMediaLibraryDidChangeNotification |
RemoteCommandStream |
MPRemoteCommandCenter command targets (20 commands) |
NowPlayingSessionStream |
MPNowPlayingSession delegate (stub; unavailable on macOS) |
#
# async
Quick start
use UNIX_EPOCH;
use *;
Highlights
NowPlayingInfoCenter— fluentNowPlayingInfobuilder covering queue state, playback progress, language options, service identifiers, live-stream flags, and playback dates.LanguageOption/LanguageOptionGroup— wrappers forMPNowPlayingInfoLanguageOptionandMPNowPlayingInfoLanguageOptionGroup.RemoteCommandCenter— zero-cost command handles for base, skip-interval, feedback, rating, playback-rate, shuffle, repeat, and language-option commands.CommandToken— RAII guard that deregisters closures on drop.Artwork—MPMediaItemArtworkfrom file paths, plus bounds inspection.- Explicit macOS stubs —
MediaLibrary,MediaQuery,MusicPlayer,MediaItem,MediaItemCollection,MediaPlaylist,VolumeView,SystemMusicPlayer, andPlayableContentDataSourceall report the Apple availability reason instead of failing mysteriously.
Example matrix
Verification
for; do ; done
License
Licensed under either of Apache-2.0 or MIT at your option.