PlayerWidget: refactor seek method.
This commit is contained in:
parent
cdf2f62ee8
commit
22f3d22998
@ -342,22 +342,13 @@ impl PlayerExt for PlayerWidget {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let duration = self.player.get_duration();
|
||||||
let destination = match direction {
|
let destination = match direction {
|
||||||
SeekDirection::Backwards => {
|
SeekDirection::Backwards if position >= offset => Some(position - offset),
|
||||||
if position >= offset {
|
SeekDirection::Forward if !duration.is_none() && position + offset <= duration => {
|
||||||
Some(position - offset)
|
Some(position + offset)
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SeekDirection::Forward => {
|
|
||||||
let duration = self.player.get_duration();
|
|
||||||
if duration != ClockTime::none() && position + offset <= duration {
|
|
||||||
Some(position + offset)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
_ => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
destination.map(|d| self.player.seek(d));
|
destination.map(|d| self.player.seek(d));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user