Fix it sometimes looping instead of going to next video when autoskipping at the end for playlists

Fix #1804
This commit is contained in:
Ajay 2023-07-28 20:42:06 -04:00
parent 31a9de252d
commit d12d847f2f
2 changed files with 9 additions and 2 deletions

View file

@ -24,7 +24,7 @@ import SubmissionNotice from "./render/SubmissionNotice";
import { Message, MessageResponse, VoteResponse } from "./messageTypes";
import { SkipButtonControlBar } from "./js-components/skipButtonControlBar";
import { getStartTimeFromUrl } from "./utils/urlParser";
import { getControls, getExistingChapters, getHashParams, isVisible } from "./utils/pageUtils";
import { getControls, getExistingChapters, getHashParams, isPlayingPlaylist, isVisible } from "./utils/pageUtils";
import { CategoryPill } from "./render/CategoryPill";
import { AnimationUtils } from "./utils/animationUtils";
import { GenericUtils } from "./utils/genericUtils";
@ -1592,8 +1592,11 @@ function skipToTime({v, skipTime, skippingSegments, openNotice, forceAutoSkip, u
// for some reason you also can't skip to 1 second before the end
if (v.loop && v.duration > 1 && skipTime[1] >= v.duration - 1) {
v.currentTime = 0;
} else if (navigator.vendor === "Apple Computer, Inc." && v.duration > 1 && skipTime[1] >= v.duration) {
} else if (v.duration > 1 && skipTime[1] >= v.duration
&& (navigator.vendor === "Apple Computer, Inc." || isPlayingPlaylist())) {
console.log("doing workaround")
// MacOS will loop otherwise #1027
// Sometimes playlists loop too #1804
v.currentTime = v.duration - 0.001;
} else {
if (inMuteSegment(skipTime[1], true)) {

View file

@ -93,4 +93,8 @@ export function getExistingChapters(currentVideoID: VideoID, duration: number):
}
return chapters;
}
export function isPlayingPlaylist() {
return !!document.URL.includes("&list=");
}