MediaPlayer
struct · ferroui-media-video · v0.5.0
struct MediaPlayer
Caller-owned playback can feed multiple views/texture consumers. Cloning a player never opens another decoder. Futures hold weak player ownership.
Members
newsame_playerdowngradeeventsplayback_sessionoptionsframeshas_pending_frame_workrequested_statesupports_playback_rateplayback_ratesupports_castingcasttracksselect_trackcaption_textset_playback_rateset_optionsset_sourcerebind_providersourcesuspend_for_device_lossplaypauseseekstopclear_sourcepoll
new
fn new(provider: Rc<dyn MediaPlayerProvider>) -> Self
same_player
fn same_player(self: &Self, other: &Self) -> bool
downgrade
fn downgrade(self: &Self) -> WeakMediaPlayer
events
fn events(self: &Self) -> &MediaEvent<MediaPlayerEvent>
playback_session
fn playback_session(self: &Self) -> MediaPlaybackSession
options
fn options(self: &Self) -> MediaPlayerOptions
frames
fn frames(self: &Self) -> Arc<FrameMailbox>
has_pending_frame_work
fn has_pending_frame_work(self: &Self) -> bool
requested_state
fn requested_state(self: &Self) -> PlaybackIntent
supports_playback_rate
fn supports_playback_rate(self: &Self) -> bool
playback_rate
fn playback_rate(self: &Self) -> f64
supports_casting
fn supports_casting(self: &Self) -> bool
cast
fn cast(self: &Self) -> MediaFuture<()>
tracks
fn tracks(self: &Self, kind: MediaTrackKind) -> Vec<MediaTrack>
select_track
fn select_track(self: &Self, kind: MediaTrackKind, id: Option<u32>) -> Result<(), MediaError>
caption_text
fn caption_text(self: &Self) -> Option<String>
set_playback_rate
fn set_playback_rate(self: &Self, rate: f64) -> Result<(), MediaError>
set_options
fn set_options(self: &Self, options: MediaPlayerOptions) -> Result<(), MediaError>
set_source
fn set_source(self: &Self, source: MediaSource) -> MediaFuture<()>
Replacement invalidates callbacks/frames immediately, even if the future is never polled. Dropping pending creation retires its provisional owner.
rebind_provider
fn rebind_provider(self: &Self, provider: Rc<dyn MediaPlayerProvider>) -> MediaFuture<()>
Replaces the renderer-bound provider without changing source ownership, audio options or requested transport state. Old callbacks and frames are invalidated immediately. The newest queued seek takes precedence over the last achieved position. Budgets belong to providers and must be shared across device generations, including retired allocations.
source
fn source(self: &Self) -> Option<MediaSource>
suspend_for_device_loss
fn suspend_for_device_loss(self: &Self)
Stop using a lost device immediately. Source and current intent remain
selected for rebind_provider; commands issued while suspended update
that intent and the latest queued seek. This does not claim completion
of outstanding native GPU work.
play
fn play(self: &Self) -> MediaFuture<()>
pause
fn pause(self: &Self) -> Result<(), MediaError>
seek
fn seek(self: &Self, position: Duration) -> MediaFuture<Duration>
stop
fn stop(self: &Self) -> MediaFuture<Duration>
clear_source
fn clear_source(self: &Self)
poll
fn poll(self: &Self) -> Result<Option<MediaFuture<()>>, MediaError>
Called by the framework render/timer lifecycle, never a new global clock. Loop restart is returned as explicit asynchronous work for that lifecycle.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedClassDefaultsErasedDestructorIntoEitherClone
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.