Skip to main content

Player

Struct Player 

Source
pub struct Player { /* private fields */ }
Expand description

A player of the media at one URL, which loads by itself: the host’s player, whose listeners hear its state, its metadata or its cues change and its position jump, at each change its host tells. A URL the system cannot play gives a player whose state is a failure.

Implementations§

Source§

impl Player

Source

pub fn new(app: &mut App, url: &str) -> Option<Ref<Player>>

A player of the media at url, which starts loading at once: a link, or a picked file’s PickedFile::url. None where the platform has no players.

Source

pub fn state(self: Handle<Self>, app: &App) -> &PlayerState

The player’s state when it last changed.

Source

pub fn metadata(self: Handle<Self>, app: &App) -> &MediaMetadata

What the media’s tags say about it, when that last changed: Media3’s getMediaMetadata.

Source

pub fn cues(self: Handle<Self>, app: &App) -> &[Cue]

The cues to show now, as the media styles them: Media3’s getCurrentCues. A PlayerView draws them over the video in the user’s caption style; an app that draws the frames itself puts a SubtitleView of them over its video.

Source

pub fn position(self: Handle<Self>, app: &App) -> Duration

Where the player is in the media now, read from the host’s player at each call: Media3’s getCurrentPosition. It moves on by itself while the player plays, which its listeners do not hear; they hear it jump. A widget that shows it while it plays reads it at each frame, with a ticker running while the state says it plays.

§Panics

Once disposed.

Source

pub fn play(self: Handle<Self>, app: &App)

Source

pub fn pause(self: Handle<Self>, app: &App)

Source

pub fn seek_to( self: Handle<Self>, app: &App, position: Duration, tolerance: SeekTolerance, )

Moves to position, or as near it as tolerance lets the system land for speed, playing on from there if it was playing; the state tells the seek under way until it lands.

Source

pub fn set_rate(self: Handle<Self>, app: &App, rate: f64)

How fast it plays, 1.0 the media’s own speed.

Source

pub fn set_volume(self: Handle<Self>, app: &App, volume: f64)

How loud it plays, from 0.0 to 1.0.

Source

pub fn set_muted(self: Handle<Self>, app: &App, muted: bool)

Whether its sound is off, apart from its volume.

Source

pub fn set_looping(self: Handle<Self>, app: &App, looping: bool)

Whether it starts again from the beginning when it reaches the end.

Source

pub fn select_audio_track(self: Handle<Self>, app: &App, id: &str)

Plays the audio track id, one of the state’s tracks, in place of the one playing.

Source

pub fn select_text_track(self: Handle<Self>, app: &App, id: Option<&str>)

Shows the text track id, one of the state’s tracks, or none: subtitles off.

Source

pub fn set_video_output( self: Handle<Self>, app: &mut App, output: Option<VideoOutput>, )

Sends the video to output from now on, and nowhere it went before; None sends it nowhere: Media3’s setVideoSurface. A PlayerView sends it to a composition layer of its own as it is mounted, and nowhere as it is unmounted; an app that draws the frames itself sends it to a reader it made, which a VideoFrameView draws.

Source

pub fn dispose(self: Handle<Self>, app: &mut App)

Stops the player and lets go of the host’s: its picture leaves the layer it was on. Its listeners hear nothing more.

Trait Implementations§

Source§

impl ChangeNotifier for Player

Source§

fn change_notifier_data(&self) -> &ChangeNotifierData

Source§

fn change_notifier_data_mut(&mut self) -> &mut ChangeNotifierData

Source§

fn will_add_listener(self: Handle<Self>, app: &mut App)

Runs before the listener is stored. Dart overrides of addListener that work before super.addListener go here.
Source§

fn did_remove_listener(self: Handle<Self>, app: &mut App)

Runs after the listener is removed. Dart overrides of removeListener that work after super.removeListener go here.
Source§

impl Debug for Player

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Player

§

impl !Send for Player

§

impl !Sync for Player

§

impl !UnwindSafe for Player

§

impl Forget for Player

§

impl Freeze for Player
where *const u8 is !null: Freeze, PhantomData<Option<Listener>>: Freeze, *const RcInner<Cell<usize>> is !null: Freeze, PhantomData<RcInner<Cell<usize>>>: Freeze, *const RcInner<dyn MediaPlayer> is !null: Freeze, PhantomData<RcInner<dyn MediaPlayer>>: Freeze, PhantomData<u8>: Freeze, PhantomData<TimeRange>: Freeze, PhantomData<MediaTrack>: Freeze, *const ArcInner<[u8]> is !null: Freeze, PhantomData<ArcInner<[u8]>>: Freeze, PhantomData<Cue>: Freeze, *const ArcInner<dyn CompositionLayer> is !null: Freeze, PhantomData<ArcInner<dyn CompositionLayer>>: Freeze, *const ArcInner<dyn VideoFrameReader> is !null: Freeze, PhantomData<ArcInner<dyn VideoFrameReader>>: Freeze,

§

impl Move for Player

§

impl Unpin for Player

§

impl UnsafeUnpin for Player

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ListenableObject for T
where T: ChangeNotifier,

Source§

fn add_listener(self: Handle<T>, app: &mut App, listener: Listener)

Register a closure to be called when the object notifies its listeners.
Source§

fn remove_listener(self: Handle<T>, app: &mut App, listener: &Listener)

Remove a previously registered closure from the list of closures that the object notifies.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>