pub struct PlayerState { /* private fields */ }Expand description
The persistant state for the video player. This must be created on the UI thread and persist across frames.
Implementations§
Source§impl PlayerState
impl PlayerState
Sourcepub fn colormatrix(&self) -> Result<Option<Rc<str>>, BackendError>
pub fn colormatrix(&self) -> Result<Option<Rc<str>>, BackendError>
§Errors
This function returns Ok(None) if the property is
unavailable, and returns an Err(_) if a libmpv error occured.
Sourcepub fn container_fps(&self) -> Result<Option<f64>, BackendError>
pub fn container_fps(&self) -> Result<Option<f64>, BackendError>
§Errors
This function returns Ok(None) if the property is
unavailable, and returns an Err(_) if a libmpv error occured.
Sourcepub fn current_demuxer(&self) -> Result<Option<Rc<str>>, BackendError>
pub fn current_demuxer(&self) -> Result<Option<Rc<str>>, BackendError>
§Errors
This function returns Ok(None) if the property is
unavailable, and returns an Err(_) if a libmpv error occured.
Sourcepub fn file_format(&self) -> Result<Option<Rc<str>>, BackendError>
pub fn file_format(&self) -> Result<Option<Rc<str>>, BackendError>
Get the file format of the currently loaded media.
§Errors
This function returns Ok(None) if the property is
unavailable, and returns an Err(_) if a libmpv error occured.
Sourcepub fn filename(&self) -> Result<Option<Rc<str>>, BackendError>
pub fn filename(&self) -> Result<Option<Rc<str>>, BackendError>
Get the filename of the currently loaded media.
§Errors
This function returns Ok(None) if the property is
unavailable, and returns an Err(_) if a libmpv error occured.
Sourcepub fn hwdec_current(&self) -> Result<Option<Rc<str>>, BackendError>
pub fn hwdec_current(&self) -> Result<Option<Rc<str>>, BackendError>
Get which hardware decoder is being used, if any.
§Errors
This function returns Ok(None) if the property is
unavailable, and returns an Err(_) if a libmpv error occured.
Sourcepub fn media_title(&self) -> Result<Option<Rc<str>>, BackendError>
pub fn media_title(&self) -> Result<Option<Rc<str>>, BackendError>
Get the title of the current media.
§Errors
This function returns Ok(None) if the property is
unavailable, and returns an Err(_) if a libmpv error occured.
Sourcepub fn muted(&self) -> Result<bool, BackendError>
pub fn muted(&self) -> Result<bool, BackendError>
Get whether playback is muted.
§Errors
This function returns Ok(None) if the property is
unavailable, and returns an Err(_) if a libmpv error occured.
Sourcepub fn video_codec(&self) -> Result<Option<Rc<str>>, BackendError>
pub fn video_codec(&self) -> Result<Option<Rc<str>>, BackendError>
Get the codec of the current video.
§Errors
This function returns Ok(None) if the property is
unavailable, and returns an Err(_) if a libmpv error occured.
Sourcepub fn video_format(&self) -> Result<Option<Rc<str>>, BackendError>
pub fn video_format(&self) -> Result<Option<Rc<str>>, BackendError>
Get the format of the current video.
§Errors
This function returns Ok(None) if the property is
unavailable, and returns an Err(_) if a libmpv error occured.
Sourcepub fn volume(&self) -> Result<f64, BackendError>
pub fn volume(&self) -> Result<f64, BackendError>
Get the current playback volume
§Errors
This function returns Ok(None) if the property is
unavailable, and returns an Err(_) if a libmpv error occured.
Sourcepub fn paused(&self) -> Result<bool, BackendError>
pub fn paused(&self) -> Result<bool, BackendError>
Get whether playback is paused.
§Errors
This function returns Ok(None) if the property is
unavailable, and returns an Err(_) if a libmpv error occured.
Sourcepub fn duration(&self) -> Result<Option<f64>, BackendError>
pub fn duration(&self) -> Result<Option<f64>, BackendError>
Get the total duration of the current video in seconds.
§Errors
This function returns Ok(None) if the property is
unavailable, and returns an Err(_) if a libmpv error occured.
Sourcepub fn dimensions(&self) -> Result<Option<(i64, i64)>, BackendError>
pub fn dimensions(&self) -> Result<Option<(i64, i64)>, BackendError>
Get the dimensions of the loaded video.
Upon success, this function returns Ok(Some(width, height)).
§Errors
If the dimensions are unavailable, it returns Ok(None). An Err(_) is
returned in the event of a BackendError.
Sourcepub fn aspect_ratio(&self) -> Result<Option<f64>, BackendError>
pub fn aspect_ratio(&self) -> Result<Option<f64>, BackendError>
Get the aspect ratio of the loaded video.
§Errors
If the dimensions are unavailable, it returns Ok(None). An Err(_) is
returned in the event of a BackendError.
Sourcepub fn new(cc: &CreationContext<'_>) -> Result<Self, BackendError>
pub fn new(cc: &CreationContext<'_>) -> Result<Self, BackendError>
Create a new PlayerState using an eframe::CreationContext.
§Panics
This function should never panic. If it does, this is a bug.
§Errors
An Err(_) is returned if there was an issue initializing the libmpv
backend.
Sourcepub fn toggle_pause(&self) -> Result<(), BackendError>
pub fn toggle_pause(&self) -> Result<(), BackendError>
Sourcepub fn play(&self) -> Result<(), BackendError>
pub fn play(&self) -> Result<(), BackendError>
§Errors
An Err(_) is returned in the event of a BackendError.
Sourcepub fn pause(&self) -> Result<(), BackendError>
pub fn pause(&self) -> Result<(), BackendError>
§Errors
An Err(_) is returned in the event of a BackendError.
Sourcepub fn toggle_mute(&self) -> Result<(), BackendError>
pub fn toggle_mute(&self) -> Result<(), BackendError>
§Errors
An Err(_) is returned in the event of a BackendError.
Sourcepub fn set_volume(&self, volume: f64) -> Result<(), BackendError>
pub fn set_volume(&self, volume: f64) -> Result<(), BackendError>
Set the playback volume as a percentage in the range 0.0..=100.0.
§Errors
An Err(_) is returned in the event of a BackendError.
Sourcepub fn time_pos(&self) -> Result<Option<f64>, BackendError>
pub fn time_pos(&self) -> Result<Option<f64>, BackendError>
Get the current playback position in seconds.
§Errors
This function returns Ok(None) if the time-pos property is
unavailable. An Err(_) is returned in the event of a BackendError.
Sourcepub fn seek_to(&self, seconds: f64) -> Result<(), BackendError>
pub fn seek_to(&self, seconds: f64) -> Result<(), BackendError>
Seek to an exact timestamp in the video.
§Errors
An Err(_) is returned in the event of a BackendError.
Sourcepub fn seek_relative(&self, seconds: f64) -> Result<(), BackendError>
pub fn seek_relative(&self, seconds: f64) -> Result<(), BackendError>
Seek to an offset relative to the current position.
§Errors
An Err(_) is returned in the event of a BackendError.
Sourcepub fn frame_drop_count(&self) -> Result<Option<i64>, BackendError>
pub fn frame_drop_count(&self) -> Result<Option<i64>, BackendError>
Sourcepub fn destroy_gl_resources(&mut self)
pub fn destroy_gl_resources(&mut self)
Call this in your app’s App::on_exit
implementation to clean up OpenGL resources.
struct App {
player: PlayerState,
}
impl eframe::App for App {
fn on_exit(&mut self, _gl: Option<&eframe::glow::Context>) {
self.player.destroy_gl_resources();
}
// ...
}Auto Trait Implementations§
impl !Freeze for PlayerState
impl !RefUnwindSafe for PlayerState
impl !Send for PlayerState
impl !Sync for PlayerState
impl !UnwindSafe for PlayerState
impl Unpin for PlayerState
impl UnsafeUnpin for PlayerState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more