pub struct AsyncPreviewPlayer { /* private fields */ }Expand description
Async wrapper around PlayerHandle.
On creation, a spawn_blocking thread opens the file, splits the player,
and starts the runner. All control methods delegate directly to the
underlying PlayerHandle — no inner Mutex.
§Usage
use ff_preview::AsyncPreviewPlayer;
use std::time::Duration;
let player = AsyncPreviewPlayer::open("clip.mp4").await?;
player.play();
player.seek(Duration::from_secs(30));
while let Some(event) = player.next_event().await { ... }Implementations§
Source§impl AsyncPreviewPlayer
impl AsyncPreviewPlayer
Sourcepub async fn open(
path: impl AsRef<Path> + Send + 'static,
) -> Result<Self, PreviewError>
pub async fn open( path: impl AsRef<Path> + Send + 'static, ) -> Result<Self, PreviewError>
Open a media file asynchronously.
File I/O and codec initialisation run on a spawn_blocking thread.
The runner is also started on a dedicated blocking thread and runs until
stop is called or EOF is reached.
§Errors
Returns PreviewError if the file is missing, unreadable, or contains
neither a video nor an audio stream.
Sourcepub fn current_pts(&self) -> Duration
pub fn current_pts(&self) -> Duration
PTS of the most recently presented frame.
Sourcepub fn duration(&self) -> Option<Duration>
pub fn duration(&self) -> Option<Duration>
Container-reported duration, or None for live / streaming sources.
Sourcepub fn pop_audio_samples(&self, n: usize) -> Vec<f32>
pub fn pop_audio_samples(&self, n: usize) -> Vec<f32>
Pull up to n interleaved stereo f32 PCM samples at 48 kHz.
Sourcepub fn poll_event(&self) -> Option<PlayerEvent>
pub fn poll_event(&self) -> Option<PlayerEvent>
Poll for the next PlayerEvent without blocking.
Returns None when no events are pending.
Sourcepub async fn next_event(&self) -> Option<PlayerEvent>
pub async fn next_event(&self) -> Option<PlayerEvent>
Await the next PlayerEvent.
Blocks in a spawn_blocking thread until an event arrives or the
channel is closed. Returns None when the runner has exited.
Trait Implementations§
Source§impl Clone for AsyncPreviewPlayer
impl Clone for AsyncPreviewPlayer
Source§fn clone(&self) -> AsyncPreviewPlayer
fn clone(&self) -> AsyncPreviewPlayer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more