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
impl Player
Sourcepub fn new(app: &mut App, url: &str) -> Option<Ref<Player>>
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.
Sourcepub fn state(self: Handle<Self>, app: &App) -> &PlayerState
pub fn state(self: Handle<Self>, app: &App) -> &PlayerState
The player’s state when it last changed.
Sourcepub fn metadata(self: Handle<Self>, app: &App) -> &MediaMetadata
pub fn metadata(self: Handle<Self>, app: &App) -> &MediaMetadata
What the media’s tags say about it, when that last changed: Media3’s getMediaMetadata.
Sourcepub fn cues(self: Handle<Self>, app: &App) -> &[Cue]
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.
Sourcepub fn position(self: Handle<Self>, app: &App) -> Duration
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.
pub fn play(self: Handle<Self>, app: &App)
pub fn pause(self: Handle<Self>, app: &App)
Sourcepub fn seek_to(
self: Handle<Self>,
app: &App,
position: Duration,
tolerance: SeekTolerance,
)
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.
Sourcepub fn set_rate(self: Handle<Self>, app: &App, rate: f64)
pub fn set_rate(self: Handle<Self>, app: &App, rate: f64)
How fast it plays, 1.0 the media’s own speed.
Sourcepub fn set_volume(self: Handle<Self>, app: &App, volume: f64)
pub fn set_volume(self: Handle<Self>, app: &App, volume: f64)
How loud it plays, from 0.0 to 1.0.
Sourcepub fn set_muted(self: Handle<Self>, app: &App, muted: bool)
pub fn set_muted(self: Handle<Self>, app: &App, muted: bool)
Whether its sound is off, apart from its volume.
Sourcepub fn set_looping(self: Handle<Self>, app: &App, looping: bool)
pub fn set_looping(self: Handle<Self>, app: &App, looping: bool)
Whether it starts again from the beginning when it reaches the end.
Sourcepub fn select_audio_track(self: Handle<Self>, app: &App, id: &str)
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.
Sourcepub fn select_text_track(self: Handle<Self>, app: &App, id: Option<&str>)
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.
Sourcepub fn set_video_output(
self: Handle<Self>,
app: &mut App,
output: Option<VideoOutput>,
)
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.
Trait Implementations§
Source§impl ChangeNotifier for Player
impl ChangeNotifier for Player
fn change_notifier_data(&self) -> &ChangeNotifierData
fn change_notifier_data_mut(&mut self) -> &mut ChangeNotifierData
Source§fn will_add_listener(self: Handle<Self>, app: &mut App)
fn will_add_listener(self: Handle<Self>, app: &mut App)
addListener that
work before super.addListener go here.Source§fn did_remove_listener(self: Handle<Self>, app: &mut App)
fn did_remove_listener(self: Handle<Self>, app: &mut App)
removeListener that
work after super.removeListener go here.