Report playback end

This commit is contained in:
Prayag Prajapati committed 2023-12-07 18:45:57 +05:30
1 parent e095863afa
commit 0af246cff2
4 files changed
+23 -2

No files matched your search

+2
View File
@@ -8,6 +8,7 @@ import LinearProgress from "@mui/material/LinearProgress";
import Typography from "@mui/material/Typography";
import {
setItem,
usePlaybackDataLoadStore,
usePlaybackStore,
} from "../../utils/store/playback";
@@ -210,6 +211,7 @@ const PlayButton = ({
setSubtitleStreamIndex(currentSubTrack);
setMediaSourceId(item.Items[0].Id);
setItem(item.Items[0]);
switch (item.Items[0].Type) {
case BaseItemKind.Movie:
+2 -2
View File
@@ -101,7 +101,7 @@ export const Card = ({
aspectRatio: cardImageAspectRatios[cardType],
}}
>
{/* {!!item.UserData && (
{!!item.UserData && (
<>
<div
className="card-indicator check"
@@ -133,7 +133,7 @@ export const Card = ({
</Typography>
</div>
</>
)} */}
)}
{/* {!!imageBlurhash && (
<Blurhash
hash={imageBlurhash}
+13
View File
@@ -83,6 +83,7 @@ export const VideoPlayer = () => {
setMediaSourceId,
setUserId,
setSeriesId,
item,
] = usePlaybackStore((state) => [
state.url,
state.startPosition,
@@ -104,6 +105,7 @@ export const VideoPlayer = () => {
state.setMediaSourceId,
state.setUserId,
state.setSeriesId,
state.item,
]);
const mediaInfo = useQuery({
@@ -504,6 +506,17 @@ export const VideoPlayer = () => {
const handleExit = async () => {
// Remove app from fullscreen
await appWindow.setFullscreen(false);
// Send playback end report
await getPlaystateApi(api).reportPlaybackStopped({
playbackStopInfo: {
Failed: false,
Item: item,
ItemId: itemId,
MediaSourceId: mediaInfo.data?.MediaSources[0].Id,
PlaySessionId: mediaInfo.data?.PlaySessionId,
PositionTicks: currentTime,
},
});
navigate(-1);
// Reset playback store
+6
View File
@@ -19,6 +19,10 @@ export const usePlaybackStore = create((set) => ({
seriesId: "",
queue: [],
episodeIndex: 0,
/**
* @type {import("@jellyfin/sdk/lib/generated-client/models/base-item-dto").BaseItemDto}
*/
item: {},
setUrl: (aurl) => set((state) => ({ ...state, url: aurl })),
setPosition: (apos) => set((state) => ({ ...state, startPosition: apos })),
setDuration: (adur) => set((state) => ({ ...state, duration: adur })),
@@ -47,6 +51,8 @@ export const usePlaybackStore = create((set) => ({
setEpisodeIndex: (aitem) =>
set((state) => ({ ...state, episodeIndex: aitem })),
}));
export const setItem = (item) =>
usePlaybackStore.setState((state) => ({ ...state, item: item }));
export const usePlaybackDataLoadStore = create((set) => ({
isPending: false,