Merge branch 'master' of https://github.com/jakequade/streamyfin into pr/106

This commit is contained in:
Fredrik Burmester
2024-09-01 17:13:33 +02:00

View File

@@ -35,10 +35,9 @@ const MIN_PLAYBACK_WIDTH = 15;
export const PlayButton: React.FC<Props> = ({ item, url, ...props }) => { export const PlayButton: React.FC<Props> = ({ item, url, ...props }) => {
const { showActionSheetWithOptions } = useActionSheet(); const { showActionSheetWithOptions } = useActionSheet();
const { setCurrentlyPlayingState } = usePlayback();
const mediaStatus = useMediaStatus()
const client = useRemoteMediaClient(); const client = useRemoteMediaClient();
const { setCurrentlyPlayingState } = usePlayback();
const mediaStatus = useMediaStatus();
const [colorAtom] = useAtom(itemThemeColorAtom); const [colorAtom] = useAtom(itemThemeColorAtom);
@@ -66,8 +65,9 @@ export const PlayButton: React.FC<Props> = ({ item, url, ...props }) => {
cancelButtonIndex, cancelButtonIndex,
}, },
async (selectedIndex: number | undefined) => { async (selectedIndex: number | undefined) => {
const currentTitle = mediaStatus?.mediaInfo?.metadata?.title const currentTitle = mediaStatus?.mediaInfo?.metadata?.title;
const isOpeningCurrentlyPlayingMedia = currentTitle && currentTitle === item?.Name const isOpeningCurrentlyPlayingMedia =
currentTitle && currentTitle === item?.Name;
switch (selectedIndex) { switch (selectedIndex) {
case 0: case 0:
@@ -81,25 +81,27 @@ export const PlayButton: React.FC<Props> = ({ item, url, ...props }) => {
CastContext.showExpandedControls(); CastContext.showExpandedControls();
return; return;
} }
client.loadMedia({ client
mediaInfo: { .loadMedia({
contentUrl: url, mediaInfo: {
contentType: "video/mp4", contentUrl: url,
metadata: { contentType: "video/mp4",
type: item.Type === "Episode" ? "tvShow" : "movie", metadata: {
title: item.Name || "", type: item.Type === "Episode" ? "tvShow" : "movie",
subtitle: item.Overview || "", title: item.Name || "",
subtitle: item.Overview || "",
},
}, },
}, startTime: 0,
startTime: 0, })
}).then(() => { .then(() => {
// state is already set when reopening current media, so skip it here. // state is already set when reopening current media, so skip it here.
if (isOpeningCurrentlyPlayingMedia) { if (isOpeningCurrentlyPlayingMedia) {
return return;
} }
setCurrentlyPlayingState({ item, url }); setCurrentlyPlayingState({ item, url });
CastContext.showExpandedControls(); CastContext.showExpandedControls();
}) });
} }
}); });
break; break;