mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Skip skipping if skip is short
This commit is contained in:
parent
9aeb64e347
commit
7c4962de80
2 changed files with 22 additions and 3 deletions
|
@ -5,6 +5,7 @@ import { MediaSegmentsApi } from '@jellyfin/sdk/lib/generated-client/api/media-s
|
|||
|
||||
import type { PlaybackManager } from 'components/playback/playbackmanager';
|
||||
import ServerConnections from 'components/ServerConnections';
|
||||
import { TICKS_PER_MILLISECOND, TICKS_PER_SECOND } from 'constants/time';
|
||||
import { currentSettings as userSettings } from 'scripts/settings/userSettings';
|
||||
import type { PlayerState } from 'types/playbackStopInfo';
|
||||
import type { Event } from 'utils/events';
|
||||
|
@ -44,7 +45,13 @@ class MediaSegmentManager extends PlaybackSubscriber {
|
|||
if (action === MediaSegmentAction.Skip) {
|
||||
// Perform skip
|
||||
if (mediaSegment.EndTicks) {
|
||||
console.debug('[MediaSegmentManager] skipping to %s ms', mediaSegment.EndTicks / 10000);
|
||||
// Do not skip if duration < 1s to avoid slow stream changes
|
||||
if (mediaSegment.StartTicks && mediaSegment.EndTicks - mediaSegment.StartTicks < TICKS_PER_SECOND) {
|
||||
console.info('[MediaSegmentManager] ignoring skipping segment with duration <1s', mediaSegment);
|
||||
return;
|
||||
}
|
||||
|
||||
console.debug('[MediaSegmentManager] skipping to %s ms', mediaSegment.EndTicks / TICKS_PER_MILLISECOND);
|
||||
this.playbackManager.seek(mediaSegment.EndTicks, this.player);
|
||||
} else {
|
||||
console.debug('[MediaSegmentManager] skipping to next item in queue');
|
||||
|
@ -88,10 +95,14 @@ class MediaSegmentManager extends PlaybackSubscriber {
|
|||
|
||||
onPlayerTimeUpdate() {
|
||||
if (this.hasSegments && this.mediaSegments.length) {
|
||||
const time = this.playbackManager.currentTime(this.player) * 10000;
|
||||
const time = this.playbackManager.currentTime(this.player) * TICKS_PER_MILLISECOND;
|
||||
const currentSegmentDetails = findCurrentSegment(this.mediaSegments, time, this.lastIndex);
|
||||
if (currentSegmentDetails) {
|
||||
console.debug('[MediaSegmentManager] found %s segment at %s ms', currentSegmentDetails.segment.Type, time / 10000, currentSegmentDetails);
|
||||
console.debug(
|
||||
'[MediaSegmentManager] found %s segment at %s ms',
|
||||
currentSegmentDetails.segment.Type,
|
||||
time / TICKS_PER_MILLISECOND,
|
||||
currentSegmentDetails);
|
||||
this.performAction(currentSegmentDetails.segment);
|
||||
this.lastIndex = currentSegmentDetails.index;
|
||||
}
|
||||
|
|
8
src/constants/time.ts
Normal file
8
src/constants/time.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
/** The number of ticks per millisecond */
|
||||
export const TICKS_PER_MILLISECOND = 10_000;
|
||||
|
||||
/** The number of ticks per second */
|
||||
export const TICKS_PER_SECOND = 1_000 * TICKS_PER_MILLISECOND;
|
||||
|
||||
/** The number of ticks per minute */
|
||||
export const TICKS_PER_MINUTE = 60 * TICKS_PER_SECOND;
|
Loading…
Add table
Add a link
Reference in a new issue