Use artist in media session for android

This commit is contained in:
Zoe Roux 2024-08-12 09:25:24 +02:00
parent e6f4f51aea
commit 660175f4ed
No known key found for this signature in database
3 changed files with 7 additions and 11 deletions

View File

@ -146,7 +146,7 @@ export const Player = ({
<Video
metadata={{
title: title ?? t("show.episodeNoMetadata"),
subtitle: subtitle ?? undefined,
artist: subtitle ?? undefined,
description: data?.overview ?? undefined,
imageUri: image?.medium,
next: next,

View File

@ -27,12 +27,14 @@ import { durationAtom, playAtom, progressAtom } from "./state";
export const MediaSessionManager = ({
title,
subtitle,
artist,
imageUri,
previous,
next,
}: {
title?: string;
subtitle?: string;
artist?: string;
imageUri?: string | null;
previous?: string;
next?: string;
@ -48,9 +50,10 @@ export const MediaSessionManager = ({
navigator.mediaSession.metadata = new MediaMetadata({
title: title,
album: subtitle,
artist: artist,
artwork: imageUri ? [{ src: imageUri }] : undefined,
});
}, [title, subtitle, imageUri]);
}, [title, subtitle, artist, imageUri]);
useEffect(() => {
if (!("mediaSession" in navigator)) return;

View File

@ -33,7 +33,7 @@ import {
} from "react";
import { useTranslation } from "react-i18next";
import { Platform } from "react-native";
import NativeVideo, { canPlay, type VideoProps } from "./video";
import NativeVideo, { canPlay, VideoMetadata, type VideoProps } from "./video";
export const playAtom = atom(true);
export const loadAtom = atom(false);
@ -114,14 +114,7 @@ export const Video = memo(function Video({
setError: (error: string | undefined) => void;
fonts?: string[];
startTime?: number | null;
metadata: {
title?: string;
subtitle?: string;
description?: string;
imageUri?: string;
previous?: string;
next?: string;
};
metadata: VideoMetadata & { next?: string; previous?: string };
} & Partial<VideoProps>) {
const ref = useRef<ElementRef<typeof NativeVideo> | null>(null);
const [isPlaying, setPlay] = useAtom(playAtom);