mirror of
https://github.com/zoriya/react-native-omni.git
synced 2026-08-16 02:44:51 +00:00
fix(cast): fix cast notification metadata
This commit is contained in:
@@ -43,8 +43,14 @@ class OmniMediaItemConverter : MediaItemConverter {
|
|||||||
val meta = mediaItem.mediaMetadata
|
val meta = mediaItem.mediaMetadata
|
||||||
val castMetadata = CastMediaMetadata(CastMediaMetadata.MEDIA_TYPE_MOVIE).apply {
|
val castMetadata = CastMediaMetadata(CastMediaMetadata.MEDIA_TYPE_MOVIE).apply {
|
||||||
meta.title?.let { putString(CastMediaMetadata.KEY_TITLE, it.toString()) }
|
meta.title?.let { putString(CastMediaMetadata.KEY_TITLE, it.toString()) }
|
||||||
meta.artist?.let { putString(CastMediaMetadata.KEY_ARTIST, it.toString()) }
|
meta.artist?.let {
|
||||||
meta.albumTitle?.let { putString(CastMediaMetadata.KEY_ALBUM_TITLE, it.toString()) }
|
putString(CastMediaMetadata.KEY_ARTIST, it.toString())
|
||||||
|
putString(CastMediaMetadata.KEY_SUBTITLE, it.toString())
|
||||||
|
}
|
||||||
|
meta.albumTitle?.let {
|
||||||
|
putString(CastMediaMetadata.KEY_ALBUM_TITLE, it.toString())
|
||||||
|
putString(CastMediaMetadata.KEY_STUDIO, it.toString())
|
||||||
|
}
|
||||||
meta.artworkUri?.let { addImage(WebImage(it)) }
|
meta.artworkUri?.let { addImage(WebImage(it)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-5
@@ -1,5 +1,5 @@
|
|||||||
import type React from "react";
|
import type React from "react";
|
||||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native";
|
import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native";
|
||||||
import {
|
import {
|
||||||
type AndroidBackend,
|
type AndroidBackend,
|
||||||
@@ -75,7 +75,8 @@ function PlayerExample({
|
|||||||
const volume = usePlayerState("volume");
|
const volume = usePlayerState("volume");
|
||||||
const isAutoQuality = usePlayerState("isAutoQuality");
|
const isAutoQuality = usePlayerState("isAutoQuality");
|
||||||
const castStatus = usePlayerState("castStatus");
|
const castStatus = usePlayerState("castStatus");
|
||||||
const [logs, setLogs] = useState<string[]>([]);
|
const [logs, setLogs] = useState<{ id: number; message: string }[]>([]);
|
||||||
|
const logId = useRef(0);
|
||||||
const [tracks, setTracks] = useState(() => ({
|
const [tracks, setTracks] = useState(() => ({
|
||||||
videos: [...player.videos],
|
videos: [...player.videos],
|
||||||
audios: [...player.audios],
|
audios: [...player.audios],
|
||||||
@@ -98,7 +99,7 @@ function PlayerExample({
|
|||||||
|
|
||||||
const pushLog = useCallback((message: string) => {
|
const pushLog = useCallback((message: string) => {
|
||||||
setLogs((prev) => {
|
setLogs((prev) => {
|
||||||
const next = [message, ...prev];
|
const next = [{ id: logId.current++, message }, ...prev];
|
||||||
return next.slice(0, 8);
|
return next.slice(0, 8);
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
@@ -484,8 +485,8 @@ function PlayerExample({
|
|||||||
<Text style={styles.logText}>Event log will appear here.</Text>
|
<Text style={styles.logText}>Event log will appear here.</Text>
|
||||||
) : (
|
) : (
|
||||||
logs.map((entry) => (
|
logs.map((entry) => (
|
||||||
<Text key={`${entry}`} style={styles.logText}>
|
<Text key={entry.id} style={styles.logText}>
|
||||||
{entry}
|
{entry.message}
|
||||||
</Text>
|
</Text>
|
||||||
))
|
))
|
||||||
)}
|
)}
|
||||||
@@ -575,6 +576,7 @@ function App(): React.JSX.Element {
|
|||||||
key={backend}
|
key={backend}
|
||||||
source={source}
|
source={source}
|
||||||
backend={{ android: backend }}
|
backend={{ android: backend }}
|
||||||
|
cast={{receiverApplicationId: "D8FB0FC1"}}
|
||||||
showNotification
|
showNotification
|
||||||
>
|
>
|
||||||
<PlayerExample
|
<PlayerExample
|
||||||
|
|||||||
Reference in New Issue
Block a user