mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Extract display mirror handling from component
This commit is contained in:
parent
efed46a42c
commit
83ebdd9012
4 changed files with 56 additions and 49 deletions
38
src/components/playback/displayMirrorManager.ts
Normal file
38
src/components/playback/displayMirrorManager.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
import type { BaseItemDto } from '@jellyfin/sdk/lib/generated-client';
|
||||
|
||||
import { playbackManager } from './playbackmanager';
|
||||
|
||||
interface PlaybackInfo {
|
||||
item: BaseItemDto;
|
||||
context?: string;
|
||||
}
|
||||
|
||||
function mirrorItem(info: PlaybackInfo, player?: unknown) {
|
||||
const { item } = info;
|
||||
|
||||
playbackManager.displayContent({
|
||||
ItemName: item.Name,
|
||||
ItemId: item.Id,
|
||||
ItemType: item.Type,
|
||||
Context: info.context
|
||||
}, player);
|
||||
}
|
||||
|
||||
function mirrorIfEnabled(info: PlaybackInfo) {
|
||||
if (info && playbackManager.enableDisplayMirroring()) {
|
||||
const playerInfo = playbackManager.getPlayerInfo();
|
||||
|
||||
if (playerInfo && !playerInfo.isLocalPlayer && playerInfo.supportedCommands.indexOf('DisplayContent') !== -1) {
|
||||
mirrorItem(info, playbackManager.getCurrentPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('viewshow', e => {
|
||||
const state = e.detail.state || {};
|
||||
const { item } = state;
|
||||
|
||||
if (item?.ServerId) {
|
||||
mirrorIfEnabled({ item });
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue