audio-only-youtube
audio-only-youtube copied to clipboard
Youtube player stuck randomly while buffering
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!
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.
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.
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.