mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Add PlaybackStopInfo Interface
This commit is contained in:
parent
92c02f8d99
commit
1a765e8564
2 changed files with 56 additions and 7 deletions
|
@ -1,6 +1,8 @@
|
||||||
import type {
|
import {
|
||||||
LibraryUpdateInfo
|
MediaType,
|
||||||
|
type LibraryUpdateInfo
|
||||||
} from '@jellyfin/sdk/lib/generated-client';
|
} from '@jellyfin/sdk/lib/generated-client';
|
||||||
|
import { ApiClient } from 'jellyfin-apiclient';
|
||||||
import React, { type FC, useCallback, useEffect, useRef } from 'react';
|
import React, { type FC, useCallback, useEffect, useRef } from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
|
@ -20,6 +22,7 @@ import MultiSelect from 'components/multiSelect/multiSelect';
|
||||||
import loading from 'components/loading/loading';
|
import loading from 'components/loading/loading';
|
||||||
import focusManager from 'components/focusManager';
|
import focusManager from 'components/focusManager';
|
||||||
import type { ParentId } from 'types/library';
|
import type { ParentId } from 'types/library';
|
||||||
|
import type { PlaybackStopInfo } from 'types/playbackStopInfo';
|
||||||
|
|
||||||
function disableEvent(e: MouseEvent) {
|
function disableEvent(e: MouseEvent) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -221,7 +224,7 @@ const ItemsContainer: FC<ItemsContainerProps> = ({
|
||||||
);
|
);
|
||||||
|
|
||||||
const onLibraryChanged = useCallback(
|
const onLibraryChanged = useCallback(
|
||||||
(_e: Event, apiClient, data: LibraryUpdateInfo) => {
|
(_e: Event, _apiClient: ApiClient, data: LibraryUpdateInfo) => {
|
||||||
if (eventsToMonitor.includes('seriestimers') || eventsToMonitor.includes('timers')) {
|
if (eventsToMonitor.includes('seriestimers') || eventsToMonitor.includes('timers')) {
|
||||||
// yes this is an assumption
|
// yes this is an assumption
|
||||||
return;
|
return;
|
||||||
|
@ -253,12 +256,12 @@ const ItemsContainer: FC<ItemsContainerProps> = ({
|
||||||
);
|
);
|
||||||
|
|
||||||
const onPlaybackStopped = useCallback(
|
const onPlaybackStopped = useCallback(
|
||||||
(_e: Event, stopInfo) => {
|
( _e: Event, stopInfo: PlaybackStopInfo ) => {
|
||||||
const state = stopInfo.state;
|
const state = stopInfo.state;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
state.NowPlayingItem
|
state.NowPlayingItem
|
||||||
&& state.NowPlayingItem.MediaType === 'Video'
|
&& state.NowPlayingItem.MediaType === MediaType.Video
|
||||||
) {
|
) {
|
||||||
if (eventsToMonitor.includes('videoplayback')) {
|
if (eventsToMonitor.includes('videoplayback')) {
|
||||||
notifyRefreshNeeded(true);
|
notifyRefreshNeeded(true);
|
||||||
|
@ -266,8 +269,8 @@ const ItemsContainer: FC<ItemsContainerProps> = ({
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
state.NowPlayingItem
|
state.NowPlayingItem
|
||||||
&& state.NowPlayingItem.MediaType === 'Audio'
|
&& state.NowPlayingItem.MediaType === MediaType.Audio
|
||||||
&& eventsToMonitor.includes('videoplayback')
|
&& eventsToMonitor.includes('audioplayback')
|
||||||
) {
|
) {
|
||||||
notifyRefreshNeeded(true);
|
notifyRefreshNeeded(true);
|
||||||
return;
|
return;
|
||||||
|
|
46
src/types/playbackStopInfo.ts
Normal file
46
src/types/playbackStopInfo.ts
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
import type {
|
||||||
|
BaseItemDto,
|
||||||
|
GroupShuffleMode,
|
||||||
|
MediaSourceInfo,
|
||||||
|
MediaType,
|
||||||
|
PlayerStateInfo
|
||||||
|
} from '@jellyfin/sdk/lib/generated-client';
|
||||||
|
|
||||||
|
export interface BufferedRange {
|
||||||
|
start?: number;
|
||||||
|
end?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PlayState extends PlayerStateInfo {
|
||||||
|
ShuffleMode?: GroupShuffleMode;
|
||||||
|
MaxStreamingBitrate?: number | null;
|
||||||
|
PlaybackStartTimeTicks?: number | null;
|
||||||
|
PlaybackRate?: number | null;
|
||||||
|
SecondarySubtitleStreamIndex?: number | null;
|
||||||
|
BufferedRanges?: BufferedRange[];
|
||||||
|
PlaySessionId?: string | null;
|
||||||
|
PlaylistItemId?: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MediaSource extends MediaSourceInfo {
|
||||||
|
enableDirectPlay?: boolean;
|
||||||
|
DefaultSecondarySubtitleStreamIndex?: number | null;
|
||||||
|
StreamUrl?: string | null;
|
||||||
|
albumLUFS?: number | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PlayerState {
|
||||||
|
PlayState: PlayState;
|
||||||
|
NowPlayingItem: BaseItemDto | null;
|
||||||
|
NextItem: BaseItemDto | null;
|
||||||
|
NextMediaType: MediaType | null;
|
||||||
|
MediaSource: MediaSource | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PlaybackStopInfo {
|
||||||
|
player: unknown; // FIXME: add a proper interface
|
||||||
|
state: PlayerState;
|
||||||
|
nextItem: BaseItemDto | null;
|
||||||
|
nextMediaType: MediaType | null;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue