docs: document some stuff
This commit is contained in:
parent
00019a036a
commit
ea1f848982
1 changed files with 12 additions and 0 deletions
12
src/lib.rs
12
src/lib.rs
|
@ -242,16 +242,19 @@ impl VideoPlayer {
|
||||||
self.muted
|
self.muted
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get if the stream ended or not.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn eos(&self) -> bool {
|
pub fn eos(&self) -> bool {
|
||||||
self.is_eos
|
self.is_eos
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get if the media will loop or not.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn looping(&self) -> bool {
|
pub fn looping(&self) -> bool {
|
||||||
self.looping
|
self.looping
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set if the media will loop or not.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn set_looping(&mut self, looping: bool) {
|
pub fn set_looping(&mut self, looping: bool) {
|
||||||
self.looping = looping;
|
self.looping = looping;
|
||||||
|
@ -267,6 +270,8 @@ impl VideoPlayer {
|
||||||
})
|
})
|
||||||
.unwrap(/* state was changed in ctor; state errors caught there */);
|
.unwrap(/* state was changed in ctor; state errors caught there */);
|
||||||
self.paused = paused;
|
self.paused = paused;
|
||||||
|
|
||||||
|
// Set restart_stream flag to make the stream restart on the next Message::NextFrame
|
||||||
if self.is_eos && !paused {
|
if self.is_eos && !paused {
|
||||||
self.restart_stream = true;
|
self.restart_stream = true;
|
||||||
}
|
}
|
||||||
|
@ -327,12 +332,15 @@ impl VideoPlayer {
|
||||||
match message {
|
match message {
|
||||||
VideoPlayerMessage::NextFrame => {
|
VideoPlayerMessage::NextFrame => {
|
||||||
let mut cmds = Vec::new();
|
let mut cmds = Vec::new();
|
||||||
|
|
||||||
let mut restart_stream = false;
|
let mut restart_stream = false;
|
||||||
if self.restart_stream {
|
if self.restart_stream {
|
||||||
restart_stream = true;
|
restart_stream = true;
|
||||||
|
// Set flag to false to avoid potentially multiple seeks
|
||||||
self.restart_stream = false;
|
self.restart_stream = false;
|
||||||
}
|
}
|
||||||
let mut eos_pause = false;
|
let mut eos_pause = false;
|
||||||
|
|
||||||
for msg in self.bus.iter() {
|
for msg in self.bus.iter() {
|
||||||
match msg.view() {
|
match msg.view() {
|
||||||
gst::MessageView::Error(err) => panic!("{:#?}", err),
|
gst::MessageView::Error(err) => panic!("{:#?}", err),
|
||||||
|
@ -347,6 +355,8 @@ impl VideoPlayer {
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't run eos_pause if restart_stream is true; fixes "pausing" after restarting a stream
|
||||||
if restart_stream {
|
if restart_stream {
|
||||||
if let Err(err) = self.restart_stream() {
|
if let Err(err) = self.restart_stream() {
|
||||||
eprintln!("cannot restart stream (can't seek): {:#?}", err);
|
eprintln!("cannot restart stream (can't seek): {:#?}", err);
|
||||||
|
@ -355,6 +365,7 @@ impl VideoPlayer {
|
||||||
self.is_eos = true;
|
self.is_eos = true;
|
||||||
self.set_paused(true);
|
self.set_paused(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Command::batch(cmds);
|
return Command::batch(cmds);
|
||||||
}
|
}
|
||||||
VideoPlayerMessage::EndOfPlayback => {}
|
VideoPlayerMessage::EndOfPlayback => {}
|
||||||
|
@ -385,6 +396,7 @@ impl VideoPlayer {
|
||||||
Image::new(self.frame_image())
|
Image::new(self.frame_image())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Restarts a stream; seeks to the first frame and unpauses, sets the `eos` flag to false.
|
||||||
pub fn restart_stream(&mut self) -> Result<(), Error> {
|
pub fn restart_stream(&mut self) -> Result<(), Error> {
|
||||||
self.is_eos = false;
|
self.is_eos = false;
|
||||||
self.set_paused(false);
|
self.set_paused(false);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue