Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add speed control #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add speed control #14

wants to merge 1 commit into from

Conversation

stpoa
Copy link

@stpoa stpoa commented Feb 16, 2023

No description provided.

@@ -100,6 +110,18 @@ pub fn simple_example(
Ok(Message::Backward) => mpv
.command(&["seek", "-5"])
.expect("Error setting MPV property"),
Ok(Message::SpeedUp) => {
let speed: f64 = mpv.get_property("speed").unwrap();
let new_speed: f64 = (speed + 0.25).min(5.0);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm no rust dev, but should min not be max here?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think he is trying to set a max allowed value.
He check min(speed + 0.25 vs 5.0), so the max alowed value will be 5.0.

For example if speed is 5.0 and u try to speed up you will stand on 5.0 due to min check.

On the other hand... I think SpeedDown method is wrong, it should be max.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants