1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Add media segment manager

This commit is contained in:
Bill Thornton 2024-10-02 17:09:59 -04:00
parent 809dba510a
commit b93450098a
7 changed files with 179 additions and 14 deletions

View file

@ -1,5 +1,6 @@
import { PlaybackErrorCode } from '@jellyfin/sdk/lib/generated-client/models/playback-error-code.js';
import { getMediaInfoApi } from '@jellyfin/sdk/lib/utils/api/media-info-api';
import { MediaType } from '@jellyfin/sdk/lib/generated-client/models/media-type';
import merge from 'lodash-es/merge';
import Screenfull from 'screenfull';
@ -19,8 +20,8 @@ import { PluginType } from '../../types/plugin.ts';
import { includesAny } from '../../utils/container.ts';
import { getItems } from '../../utils/jellyfin-apiclient/getItems.ts';
import { getItemBackdropImageUrl } from '../../utils/jellyfin-apiclient/backdropImage';
import { MediaType } from '@jellyfin/sdk/lib/generated-client/models/media-type';
import { bindMediaSegmentManager } from 'apps/stable/features/playback/utils/mediaSegmentManager';
import { MediaError } from 'types/mediaError';
import { getMediaError } from 'utils/mediaError';
import { toApi } from 'utils/jellyfin-apiclient/compat';
@ -3663,6 +3664,8 @@ export class PlaybackManager {
Events.on(serverNotifications, 'ServerRestarting', self.setDefaultPlayerActive.bind(self));
});
}
bindMediaSegmentManager(self);
}
getCurrentPlayer() {

View file

@ -2,6 +2,7 @@ import { MediaSegmentType } from '@jellyfin/sdk/lib/generated-client/models/medi
import escapeHTML from 'escape-html';
import { MediaSegmentAction } from 'apps/stable/features/playback/constants/mediaSegmentAction';
import { getId, getMediaSegmentAction } from 'apps/stable/features/playback/utils/mediaSegmentSettings';
import appSettings from '../../scripts/settings/appSettings';
import { appHost } from '../apphost';
@ -54,18 +55,23 @@ function populateMediaSegments(container, userSettings) {
})
.join('');
const segmentSettings = Object.values(MediaSegmentType)
.map(segmentType => {
const segmentTypeLabel = globalize.translate('LabelMediaSegmentsType', globalize.translate(`MediaSegmentType.${segmentType}`));
const id = `segmentTypeAction__${segmentType}`;
selectedValues[id] = userSettings.get(id, false) || MediaSegmentAction.None;
return `<div class="selectContainer">
<select is="emby-select" id="${id}" class="segmentTypeAction" label="${segmentTypeLabel}">
${actionOptions}
</select>
const segmentSettings = [
// List the types in a logical order (and exclude "Unknown" type)
MediaSegmentType.Intro,
MediaSegmentType.Preview,
MediaSegmentType.Recap,
MediaSegmentType.Commercial,
MediaSegmentType.Outro
].map(segmentType => {
const segmentTypeLabel = globalize.translate('LabelMediaSegmentsType', globalize.translate(`MediaSegmentType.${segmentType}`));
const id = getId(segmentType);
selectedValues[id] = getMediaSegmentAction(userSettings, segmentType) || MediaSegmentAction.None;
return `<div class="selectContainer">
<select is="emby-select" id="${id}" class="segmentTypeAction" label="${segmentTypeLabel}">
${actionOptions}
</select>
</div>`;
})
.join('');
}).join('');
container.innerHTML = segmentSettings;