feat: cross-platform titlebar, video transfers and client cleanup
Continuous Integration / build_web (push) Failing after 0s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped
Continuous Integration / build_web (push) Failing after 0s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped
Adds frameless-window controls for Windows/Linux (native traffic lights on macOS), keeps transfers at the current position for video, lets the video player use the same sync/device controls as the media bar, and removes dead code plus assorted UI/perf issues.
This commit is contained in:
1 parent
4bdd0139bf
commit
6675a55957
26 files changed
+561
-316
No files matched your search
@@ -56,6 +56,8 @@ export interface PlaybackInfoOptions {
|
||||
currentEpisodeId?: string;
|
||||
playlistItem?: boolean;
|
||||
playlistItemId?: string;
|
||||
/** Start the stream at this position (used by transfers). */
|
||||
startPositionTicks?: number;
|
||||
}
|
||||
|
||||
export async function getPlaybackInfo(
|
||||
@@ -70,6 +72,7 @@ export async function getPlaybackInfo(
|
||||
currentEpisodeId,
|
||||
playlistItem,
|
||||
playlistItemId,
|
||||
startPositionTicks,
|
||||
} = options;
|
||||
|
||||
let result: any;
|
||||
@@ -223,7 +226,8 @@ export async function getPlaybackInfo(
|
||||
audioStreamIndex: Number(audioStreamIndex),
|
||||
subtitleStreamIndex: currentSubTrack === "nosub" ? -1 : currentSubTrack,
|
||||
itemId: targetItem.Id,
|
||||
startTimeTicks: targetItem.UserData?.PlaybackPositionTicks,
|
||||
startTimeTicks:
|
||||
startPositionTicks ?? targetItem.UserData?.PlaybackPositionTicks,
|
||||
userId: userId,
|
||||
mediaSourceId: targetItem.MediaSources?.[0]?.Id,
|
||||
playbackInfoDto: {
|
||||
|
||||
@@ -191,7 +191,9 @@ export const transferSessionToLocal = async (
|
||||
enableUserData: true,
|
||||
})
|
||||
).data.Items?.[0] ?? item;
|
||||
const playback = await getPlaybackInfo(api, userId, fullItem);
|
||||
const playback = await getPlaybackInfo(api, userId, fullItem, {
|
||||
startPositionTicks: positionTicks,
|
||||
});
|
||||
const queueItems: BaseItemDto[] = playback.item?.Items?.length
|
||||
? playback.item.Items
|
||||
: queue;
|
||||
@@ -211,15 +213,28 @@ export const transferSessionToLocal = async (
|
||||
});
|
||||
}
|
||||
|
||||
// Transfer, not cast: the remote device should stop.
|
||||
try {
|
||||
await getSessionApi(api).sendPlaystateCommand({
|
||||
sessionId: session.Id,
|
||||
command: "Stop",
|
||||
controllingUserId: userId,
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn("Could not stop the remote session", error);
|
||||
// Transfer, not cast: the remote device should stop. Some clients drop
|
||||
// Stop or ignore it while switching streams, so fall back to Pause and
|
||||
// verify that it actually stopped.
|
||||
for (const command of [PlaystateCommand.Stop, PlaystateCommand.Pause]) {
|
||||
try {
|
||||
await getSessionApi(api).sendPlaystateCommand({
|
||||
sessionId: session.Id,
|
||||
command,
|
||||
controllingUserId: userId,
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn("Could not stop the remote session", error);
|
||||
}
|
||||
await sleep(400);
|
||||
try {
|
||||
const target = (await getSessionApi(api).getSessions()).data.find(
|
||||
(entry) => entry.Id === session.Id,
|
||||
);
|
||||
if (!target?.NowPlayingItem || target.PlayState?.IsPaused) return kind;
|
||||
} catch {
|
||||
return kind;
|
||||
}
|
||||
}
|
||||
|
||||
return kind;
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import { useState } from "react";
|
||||
import useKonami from "react-use-konami";
|
||||
|
||||
export const useKonamiEasterEgg = () => {
|
||||
const [easterEgg, setEasterEgg] = useState(false);
|
||||
const sixtyNine = () => {
|
||||
setEasterEgg(true);
|
||||
};
|
||||
|
||||
useKonami(sixtyNine, {
|
||||
code: [
|
||||
"ArrowUp",
|
||||
"ArrowUp",
|
||||
"ArrowDown",
|
||||
"ArrowDown",
|
||||
"ArrowLeft",
|
||||
"ArrowRight",
|
||||
"ArrowLeft",
|
||||
"ArrowRight",
|
||||
"b",
|
||||
"a",
|
||||
],
|
||||
});
|
||||
|
||||
return [easterEgg, setEasterEgg] as const;
|
||||
};
|
||||
@@ -1,142 +0,0 @@
|
||||
import { WebviewWindow } from "@tauri-apps/api/webviewWindow";
|
||||
import type ReactPlayer from "react-player";
|
||||
|
||||
type VideoPlayerState = {
|
||||
ref: React.RefObject<ReactPlayer | null>;
|
||||
isPlayerReady: boolean;
|
||||
isPlayerPlaying: boolean;
|
||||
isPlayerMuted: boolean;
|
||||
isPlayerFullscreen: boolean;
|
||||
/**
|
||||
* Volume of the player
|
||||
* @type {number} 0 to 1
|
||||
*/
|
||||
playerVolume: number;
|
||||
isSeeking: boolean;
|
||||
sliderSeek: number;
|
||||
/**
|
||||
* Progress of the video
|
||||
* @type {number} in C# ticks
|
||||
*/
|
||||
progress: number;
|
||||
isHovering: boolean;
|
||||
};
|
||||
|
||||
export enum VideoPlayerActionKind {
|
||||
SET_PLAYER_REF = "SET_PLAYER_REF",
|
||||
SET_PLAYER_READY = "SET_PLAYER_READY",
|
||||
SET_PLAYER_PLAYING = "SET_PLAYER_PLAYING",
|
||||
SET_PLAYER_MUTED = "SET_PLAYER_MUTED",
|
||||
SET_PLAYER_FULLSCREEN = "SET_PLAYER_FULLSCREEN",
|
||||
SET_PLAYER_VOLUME = "SET_PLAYER_VOLUME",
|
||||
SET_PLAYER_VOLUME_UP_BY_STEP = "SET_PLAYER_VOLUME_BY_STEP",
|
||||
SET_PLAYER_VOLUME_DOWN_BY_STEP = "SET_PLAYER_VOLUME_DOWN_STEP",
|
||||
SET_SEEKING = "SET_SEEKING",
|
||||
SET_SLIDER_SEEK = "SET_SLIDER_SEEK",
|
||||
SET_PROGRESS = "SET_PROGRESS",
|
||||
SET_HOVERING = "SET_HOVERING",
|
||||
TOGGLE_PLAYER_PLAYING = "TOGGLE_PLAYER_PLAYING",
|
||||
TOGGLE_PLAYER_FULLSCREEN = "TOGGLE_PLAYER_FULLSCREEN",
|
||||
TOGGLE_PLAYER_MUTED = "TOGGLE_PLAYER_MUTED",
|
||||
}
|
||||
|
||||
export interface VideoPlayerAction {
|
||||
type: VideoPlayerActionKind;
|
||||
payload?: number | boolean | React.RefObject<HTMLVideoElement>;
|
||||
}
|
||||
|
||||
const reducer = (
|
||||
state: VideoPlayerState,
|
||||
action: VideoPlayerAction,
|
||||
): VideoPlayerState => {
|
||||
switch (action.type) {
|
||||
case VideoPlayerActionKind.SET_PLAYER_REF:
|
||||
return {
|
||||
...state,
|
||||
ref: action.payload as unknown as React.RefObject<ReactPlayer | null>,
|
||||
};
|
||||
case VideoPlayerActionKind.SET_PLAYER_READY:
|
||||
return {
|
||||
...state,
|
||||
isPlayerReady: action.payload as boolean,
|
||||
};
|
||||
case VideoPlayerActionKind.SET_PLAYER_PLAYING:
|
||||
return {
|
||||
...state,
|
||||
isPlayerPlaying: action.payload as boolean,
|
||||
};
|
||||
case VideoPlayerActionKind.SET_PLAYER_MUTED:
|
||||
return {
|
||||
...state,
|
||||
isPlayerMuted: action.payload as boolean,
|
||||
};
|
||||
case VideoPlayerActionKind.SET_PLAYER_FULLSCREEN:
|
||||
return {
|
||||
...state,
|
||||
isPlayerFullscreen: action.payload as boolean,
|
||||
};
|
||||
case VideoPlayerActionKind.SET_PLAYER_VOLUME:
|
||||
return {
|
||||
...state,
|
||||
playerVolume: action.payload as number,
|
||||
};
|
||||
case VideoPlayerActionKind.SET_SEEKING:
|
||||
return {
|
||||
...state,
|
||||
isSeeking: action.payload as boolean,
|
||||
};
|
||||
case VideoPlayerActionKind.SET_SLIDER_SEEK:
|
||||
return {
|
||||
...state,
|
||||
sliderSeek: action.payload as number,
|
||||
};
|
||||
case VideoPlayerActionKind.SET_PROGRESS:
|
||||
return {
|
||||
...state,
|
||||
progress: action.payload as number,
|
||||
};
|
||||
case VideoPlayerActionKind.SET_HOVERING:
|
||||
return {
|
||||
...state,
|
||||
isHovering: action.payload as boolean,
|
||||
};
|
||||
case VideoPlayerActionKind.TOGGLE_PLAYER_PLAYING:
|
||||
return {
|
||||
...state,
|
||||
isPlayerPlaying: !state.isPlayerPlaying,
|
||||
};
|
||||
case VideoPlayerActionKind.TOGGLE_PLAYER_FULLSCREEN: {
|
||||
WebviewWindow.getCurrent().setFullscreen(!state.isPlayerFullscreen);
|
||||
return {
|
||||
...state,
|
||||
isPlayerFullscreen: !state.isPlayerFullscreen,
|
||||
};
|
||||
}
|
||||
case VideoPlayerActionKind.TOGGLE_PLAYER_MUTED:
|
||||
return {
|
||||
...state,
|
||||
isPlayerMuted: !state.isPlayerMuted,
|
||||
};
|
||||
case VideoPlayerActionKind.SET_PLAYER_VOLUME_UP_BY_STEP:
|
||||
return {
|
||||
...state,
|
||||
playerVolume: Math.min(
|
||||
1,
|
||||
Math.max(0, state.playerVolume + (action.payload as number)),
|
||||
),
|
||||
};
|
||||
case VideoPlayerActionKind.SET_PLAYER_VOLUME_DOWN_BY_STEP:
|
||||
return {
|
||||
...state,
|
||||
playerVolume: Math.min(
|
||||
1,
|
||||
Math.max(0, state.playerVolume - (action.payload as number)),
|
||||
),
|
||||
};
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export default reducer;
|
||||
@@ -130,7 +130,7 @@ type PlaybackStoreState = {
|
||||
* This is used to show the volume change indicator in the UI
|
||||
*/
|
||||
isVolumeInidcatorVisible: boolean;
|
||||
volumeIndicatorVisibleTimeoutId: NodeJS.Timeout | null;
|
||||
volumeIndicatorVisibleTimeoutId: ReturnType<typeof setTimeout> | null;
|
||||
};
|
||||
|
||||
type PlaybackStoreActions = {
|
||||
@@ -690,7 +690,11 @@ export const playItem = (args: {
|
||||
state.playbackStream = args.playbackStream;
|
||||
state.playsessionId = args.playsessionId;
|
||||
state.metadata = args.metadata;
|
||||
state.playerState.currentTime = args.userDataPlayedPositionTicks;
|
||||
// Transfers pass an explicit start position; it must win over the
|
||||
// item's saved resume point (otherwise the video jumps back).
|
||||
state.playerState.currentTime =
|
||||
args.metadata.userDataLastPlayedPositionTicks ??
|
||||
args.userDataPlayedPositionTicks;
|
||||
state.userId = args.userId;
|
||||
state.playerState.isPlayerPlaying = true;
|
||||
state.playerState.isPlayerReady = false; // Reset player ready state
|
||||
|
||||
Reference in new issue
Block a user