Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

How to make the "currentTime" method work correctly? #23

Closed
abvas opened this issue Aug 1, 2023 · 4 comments
Closed

How to make the "currentTime" method work correctly? #23

abvas opened this issue Aug 1, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@abvas
Copy link

abvas commented Aug 1, 2023

How to make the "currentTime" method work correctly?

I can't seem to get the "currentTime" method to work properly.
That's what I get?
When using the "currentTime" method, I get an ever-spinning spinner.

Desired behavior?
When using the "currentTime" method, it should look like a pause without a spinning spinner.

Here is the simplest example:

<script type="module" src="https://cdn.jsdelivr.net/npm/youtube-video-element@0"></script>
<youtube-video controls src="https://www.youtube.com/watch?v=rubNgGj3pYo"></youtube-video>

<script>
window.addEventListener("load", function() {
    document.querySelector('youtube-video').currentTime = 20;
})
</script>

Here is a live demo:
https://codepen.io/abvas/pen/LYXMBLx

What am I doing wrong? Is it possible somehow to solve this?
With other web components (eg <vimeo-video> and <hls-video>) this behavior is not observed.

Thank you.

@dylanjha
Copy link
Contributor

Hi @abvas -- thanks for reporting. Just a stab in the dark, but I'm guessing this is related to the youtube embed being in an iframe and the async nature of that. If you wait until the video is playing does currentTime= work?

I don't know when we'll have time to fix this behavior, but open to anyone who can poke around and help debug it

@abvas
Copy link
Author

abvas commented Aug 15, 2023

Hi @dylanjha!

This behavior is observed only before the first launch of the video. If the video is already playing, or if the video was started and then paused, then the currentTime method works fine.

Thank you.

@luwes luwes added the bug Something isn't working label Sep 14, 2023
@luwes luwes closed this as completed in 92f7de8 Sep 15, 2023
luwes added a commit that referenced this issue Sep 15, 2023
luwes added a commit that referenced this issue Sep 15, 2023
@luwes
Copy link
Contributor

luwes commented Sep 15, 2023

this should be fixed now, let me know if it's not working on your end.
https://youtube-video-element-mux.vercel.app/

@luwes luwes self-assigned this Sep 15, 2023
@abvas
Copy link
Author

abvas commented Sep 16, 2023

Version 1.0.0
Now everything works great.
Thank you very much!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants