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