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

Youtube player stuck randomly while buffering #42

Open
skybldev opened this issue Oct 11, 2018 · 3 comments
Open

Youtube player stuck randomly while buffering #42

skybldev opened this issue Oct 11, 2018 · 3 comments

Comments

@skybldev
Copy link

I have a slow internet, only ~3.75mbits/s D and ~1mbits/s U. So I would like to thank you for your awesome extension, it really helps to save bandwidth especially when gaming or downloading large files.

One problem, though, is that when it buffers, it skips to the start a few times, sometimes not actually ending up playing and getting stuck as paused. Is there a fix for this? Thanks!

@Ashish-Bansal
Copy link
Owner

Hi,

I'm glad it helped you.

One problem, though, is that when it buffers, it skips to the start a few times, sometimes not actually ending up playing and getting stuck as paused. Is there a fix for this? Thanks!

I'm aware that sometimes it gets stuck randomly but the frequency is quite low for me. There isn't defined way by which I can reproduce the problem. So, due to time constraints, it's bit difficult to investigate in the issue and figure out the reason for the same.

@Ashish-Bansal Ashish-Bansal changed the title Media skips to start when buffering Youtube player stuck randomly while buffering Mar 4, 2019
@max-hk
Copy link
Contributor

max-hk commented Mar 29, 2019

I think the problem is more likely a bug in Google's end, since it occurs sometimes in my machine even with audio-only-youtube disabled.

I have ublock-origin enabled and can't tell if the problem is caused by adblocker or not.

@Thunderarea
Copy link

Thunderarea commented May 17, 2020

There is a solution to this problem. It's not Google's bug. The problem there is in the content script (line 120-123) in the function "makeSetAudioURL".
When a new audio url arrives the following function takes it and sets it as the source of the video and sets the current video time to 0. This causes the problem.

function makeSetAudioURL(videoElement: HTMLVideoElement, url: string) {
  function setAudioURL() {
    if (url === '' || videoElement.src === url) {
      return;
    }

    videoElement.pause();
    videoElement.src = url;
    videoElement.currentTime = 0; // <= the bug
    videoElement.play();
  }
  return setAudioURL;
}

A litlle change in this code will solve the problem. The solution is to save the current video time before changing its source. So when a new url arrives, the video won't play again from the beggining, but will continue from the time that it paused.

   videoElement.pause();
   let curTime = videoElement.currentTime;
   videoElement.src = url;
   videoElement.currentTime = curTime;
   videoElement.play();

@Ashish-Bansal change this bit of code and the problem will be solved.

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

No branches or pull requests

4 participants