carplay fixes

This commit is contained in:
Violet Caulfield
2025-02-12 15:18:21 -06:00
parent 3a542c55ce
commit 9d9577f65b
3 changed files with 9 additions and 8 deletions

View File

@@ -47,7 +47,7 @@ export function fetchItemImage(itemId: string, imageType: ImageType, width: numb
});
}
function getImageFilePath(itemId: string, width: number, height: number, imageType: ImageType) {
export function getImageFilePath(itemId: string, width: number, height: number, imageType: ImageType) {
return `${Dirs.CacheDir}/images/${itemId}_${imageType}_${width}x${height}.png`
}

View File

@@ -21,14 +21,14 @@ const CarPlayHome : ListTemplate = new ListTemplate({
onItemSelect: async ({ index }) => {
switch (index) {
case 1:
case 0:
break;
case 2:
case 1:
const tracks = await fetchRecentlyPlayed()
CarPlay.pushTemplate(CarPlayRecentlyPlayed(tracks))
break;
case 3:
case 2:
break;

View File

@@ -1,5 +1,6 @@
import { getImageFilePath } from "../../api/queries/functions/images";
import Client from "../../api/client";
import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
import { BaseItemDto, ImageType } from "@jellyfin/sdk/lib/generated-client/models";
import { getImageApi } from "@jellyfin/sdk/lib/utils/api";
import { GridTemplate, ListTemplate } from "react-native-carplay";
@@ -9,9 +10,9 @@ export const CarPlayRecentlyPlayed = (recentTracks : BaseItemDto[]) => new ListT
return {
id: track.Id!,
text: track.Name ? track.Name : "Untitled Track",
imgUrls : [
Client.api ? getImageApi(Client.api).getItemImageUrlById(track.Id!) : ""
]
image: {
uri: `file://${getImageFilePath(track.Id!, 150, 150, ImageType.Primary)}`
}
}
})
})