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

Changing video current play time #3711

Closed
WINOFFRG opened this issue Oct 21, 2021 · 2 comments
Closed

Changing video current play time #3711

WINOFFRG opened this issue Oct 21, 2021 · 2 comments
Labels
status: archived Archived and locked; will not be updated type: question A question from the community

Comments

@WINOFFRG
Copy link
Contributor

Have you read the Tutorials?
Yes

Have you read the FAQ and checked for duplicate open issues?
Yes

What version of Shaka Player are you using?
3.2.0

Please ask your question
Hello! I am trying to create custom buttons that are able to skip a video ±X time. So, for that, I decided to look into the existing rewind/forward button. Upon checking I found that they just changed the trickPlay rate. Trick play internally had a playRateController which has some private methods to set the rate.
At this part, I got a bit confused on how to reuse this existing play rate controller to just skip the video ±X seconds.

Later, I found that on the video tag object we have a method named currentTime and upon changing its value I was able to update the current play time.

So, is there any way I could reuse the existing playRateController to update the current play time? If not, then is it okay to update the currentTime in the new button using the second way as I explained above? :)

@WINOFFRG WINOFFRG added the type: question A question from the community label Oct 21, 2021
@TheModMaker
Copy link
Contributor

PlayRateController is an internal component and shouldn't be used by apps. Trick play is fast forward, which controls the playback rate, not directly the current time. For positive playback rates, you can just set the video.playbackRate; for rewind (or fast forward if you want), you can use player.trickPlay(2).

The correct way to change the current time is setting video.currentTime. For example:

myButton.addEventListener('click', () => {
  video.currentTime += 10;
});

@WINOFFRG
Copy link
Contributor Author

Understood! Thanks.

@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Dec 21, 2021
@shaka-project shaka-project locked and limited conversation to collaborators Dec 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated type: question A question from the community
Projects
None yet
Development

No branches or pull requests

3 participants