diff --git a/src/elements/emby-itemscontainer/ItemsContainer.tsx b/src/elements/emby-itemscontainer/ItemsContainer.tsx index 44dc0c35d6..9d30c2b868 100644 --- a/src/elements/emby-itemscontainer/ItemsContainer.tsx +++ b/src/elements/emby-itemscontainer/ItemsContainer.tsx @@ -1,6 +1,8 @@ -import type { - LibraryUpdateInfo +import { + MediaType, + type LibraryUpdateInfo } from '@jellyfin/sdk/lib/generated-client'; +import { ApiClient } from 'jellyfin-apiclient'; import React, { type FC, useCallback, useEffect, useRef } from 'react'; import classNames from 'classnames'; import Box from '@mui/material/Box'; @@ -20,6 +22,7 @@ import MultiSelect from 'components/multiSelect/multiSelect'; import loading from 'components/loading/loading'; import focusManager from 'components/focusManager'; import type { ParentId } from 'types/library'; +import type { PlaybackStopInfo } from 'types/playbackStopInfo'; function disableEvent(e: MouseEvent) { e.preventDefault(); @@ -221,7 +224,7 @@ const ItemsContainer: FC = ({ ); const onLibraryChanged = useCallback( - (_e: Event, apiClient, data: LibraryUpdateInfo) => { + (_e: Event, _apiClient: ApiClient, data: LibraryUpdateInfo) => { if (eventsToMonitor.includes('seriestimers') || eventsToMonitor.includes('timers')) { // yes this is an assumption return; @@ -253,12 +256,12 @@ const ItemsContainer: FC = ({ ); const onPlaybackStopped = useCallback( - (_e: Event, stopInfo) => { + ( _e: Event, stopInfo: PlaybackStopInfo ) => { const state = stopInfo.state; if ( state.NowPlayingItem - && state.NowPlayingItem.MediaType === 'Video' + && state.NowPlayingItem.MediaType === MediaType.Video ) { if (eventsToMonitor.includes('videoplayback')) { notifyRefreshNeeded(true); @@ -266,8 +269,8 @@ const ItemsContainer: FC = ({ } } else if ( state.NowPlayingItem - && state.NowPlayingItem.MediaType === 'Audio' - && eventsToMonitor.includes('videoplayback') + && state.NowPlayingItem.MediaType === MediaType.Audio + && eventsToMonitor.includes('audioplayback') ) { notifyRefreshNeeded(true); return; diff --git a/src/types/playbackStopInfo.ts b/src/types/playbackStopInfo.ts new file mode 100644 index 0000000000..04c7950cb4 --- /dev/null +++ b/src/types/playbackStopInfo.ts @@ -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; +} +