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

fix playback speed plugin #462

Merged
merged 9 commits into from
Nov 1, 2021
Merged

Conversation

Araxeus
Copy link
Collaborator

@Araxeus Araxeus commented Oct 30, 2021

  • Fixes memory leaks from observer within observer and unnecessary observers watching the whole document
    see Audio compressor plugin #288 (review)

  • This also normalize the steps of the slider to be 0.125 (1/8)
    see here all available levels obtained by dragging the bar:

    var x = []
    for(let i=0; i<=2; i+=0.125) x.push(i || 0.07)
    console.log(x)
    // (17) [0.07, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1, 1.125, 1.25, 1.375, 1.5, 1.625, 1.75, 1.875, 2]
  • This also adds a mousewheel listener to the playback speed bar, which allows more precise tuning of the current speed - 0.07 up to 16, in increments of 0.01 (good luck getting to 16 lol)

Copy link
Owner

@th-ch th-ch left a comment

Choose a reason for hiding this comment

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

The mousewheel works fine but when clicking directly on the slider, the value updates in the UI but the playback rate is not changed anymore, is it expected?

plugins/playback-speed/front.js Outdated Show resolved Hide resolved
@Araxeus
Copy link
Collaborator Author

Araxeus commented Nov 1, 2021

The mousewheel works fine but when clicking directly on the slider, the value updates in the UI but the playback rate is not changed anymore, is it expected?

@th-ch Did you get any errors thrown?
if you use the mousewheel after moving the slider - does it use the "fake video speed" displayed near the slider or the real video speed? (in other words I'm actually asking if it saves to the playbackSpeed variable when moving the slider)

can you add some logging to see where does it get stuck? in:

slider.addEventListener('immediate-value-change', () => {
playbackSpeed = computePlayBackSpeed($('#playback-speed-slider #sliderBar').value);
if (isNaN(playbackSpeed)) {
playbackSpeed = 1;
}
updatePlayBackSpeed();

$('#playback-speed-slider #sliderBar').value || 0.07 should always work, the value is always a number

updatePlayBackSpeed() the same function that is executed with the mousewheel so I really have no idea whats going on here

Sadly I can't really do much without more info, since I cant reproduce this

@Araxeus
Copy link
Collaborator Author

Araxeus commented Nov 1, 2021

@th-ch I figured it out - 'immediate-value-change' is a polymer event which only fire on drag, not click. so I had to add a 'd' on there and use 'immediate-value-changed'

Except that event doesn't bubble up apparently so I had to set it up straight on the slider, which required waiting for its first load to find it in the dom. anyways it should be fixed now with 41285ac

ps. the polymer elements docs link is weird, the url change and if you refresh you lose almost all the documentation :|

Copy link
Owner

@th-ch th-ch left a comment

Choose a reason for hiding this comment

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

Confirmed it now works fine on my side with both click and mousewheel 🎉
Looks good, thanks for the improvement! ✅

@th-ch th-ch merged commit fc254db into th-ch:master Nov 1, 2021
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.

2 participants