fix: bug since media playback refactor

This commit is contained in:
Fredrik Burmester
2024-08-22 16:46:53 +02:00
parent 06877f4339
commit e8dc9e759a
3 changed files with 15 additions and 26 deletions

View File

@@ -84,7 +84,7 @@ export default function page() {
useEffect(() => { useEffect(() => {
navigation.setOptions({ navigation.setOptions({
title: albums?.Items?.[0].AlbumArtist, title: albums?.Items?.[0]?.AlbumArtist || "",
}); });
}, [albums]); }, [albums]);

View File

@@ -1,9 +1,6 @@
import { TouchableOpacity, View, ViewProps } from "react-native";
import { Text } from "@/components/common/Text";
import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models"; import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
import ArtistPoster from "../ArtistPoster";
import { runtimeTicksToMinutes, runtimeTicksToSeconds } from "@/utils/time";
import { useRouter } from "expo-router"; import { useRouter } from "expo-router";
import { View, ViewProps } from "react-native";
import { SongsListItem } from "./SongsListItem"; import { SongsListItem } from "./SongsListItem";
interface Props extends ViewProps { interface Props extends ViewProps {

View File

@@ -1,27 +1,20 @@
import {
TouchableOpacity,
TouchableOpacityProps,
View,
ViewProps,
} from "react-native";
import { Text } from "@/components/common/Text"; import { Text } from "@/components/common/Text";
import index from "@/app/(auth)/(tabs)/home";
import { runtimeTicksToSeconds } from "@/utils/time";
import { router } from "expo-router";
import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
import { getStreamUrl } from "@/utils/jellyfin/media/getStreamUrl";
import { useAtom } from "jotai";
import { apiAtom, userAtom } from "@/providers/JellyfinProvider"; import { apiAtom, userAtom } from "@/providers/JellyfinProvider";
import { usePlayback } from "@/providers/PlaybackProvider";
import { getStreamUrl } from "@/utils/jellyfin/media/getStreamUrl";
import { chromecastProfile } from "@/utils/profiles/chromecast"; import { chromecastProfile } from "@/utils/profiles/chromecast";
import ios from "@/utils/profiles/ios";
import { runtimeTicksToSeconds } from "@/utils/time";
import { useActionSheet } from "@expo/react-native-action-sheet";
import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api"; import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api";
import { useAtom } from "jotai";
import { TouchableOpacity, TouchableOpacityProps, View } from "react-native";
import CastContext, { import CastContext, {
PlayServicesState, PlayServicesState,
useCastDevice, useCastDevice,
useRemoteMediaClient, useRemoteMediaClient,
} from "react-native-google-cast"; } from "react-native-google-cast";
import { currentlyPlayingItemAtom, playingAtom } from "../CurrentlyPlayingBar";
import { useActionSheet } from "@expo/react-native-action-sheet";
import ios from "@/utils/profiles/ios";
interface Props extends TouchableOpacityProps { interface Props extends TouchableOpacityProps {
collectionId: string; collectionId: string;
@@ -42,12 +35,12 @@ export const SongsListItem: React.FC<Props> = ({
const [api] = useAtom(apiAtom); const [api] = useAtom(apiAtom);
const [user] = useAtom(userAtom); const [user] = useAtom(userAtom);
const castDevice = useCastDevice(); const castDevice = useCastDevice();
const [, setCp] = useAtom(currentlyPlayingItemAtom);
const [, setPlaying] = useAtom(playingAtom);
const client = useRemoteMediaClient(); const client = useRemoteMediaClient();
const { showActionSheetWithOptions } = useActionSheet(); const { showActionSheetWithOptions } = useActionSheet();
const { setCurrentlyPlayingState } = usePlayback();
const openSelect = () => { const openSelect = () => {
if (!castDevice?.deviceId) { if (!castDevice?.deviceId) {
play("device"); play("device");
@@ -73,7 +66,7 @@ export const SongsListItem: React.FC<Props> = ({
case cancelButtonIndex: case cancelButtonIndex:
break; break;
} }
}, }
); );
}; };
@@ -118,11 +111,10 @@ export const SongsListItem: React.FC<Props> = ({
} }
}); });
} else { } else {
setCp({ setCurrentlyPlayingState({
item, item,
playbackUrl: url, url,
}); });
setPlaying(true);
} }
}; };