mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-01-15 23:59:08 +00:00
chore: code improvements refactor
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import { Feather, FontAwesome, Ionicons } from "@expo/vector-icons";
|
||||
import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
|
||||
import React, { useEffect } from "react";
|
||||
import { TouchableOpacity, View } from "react-native";
|
||||
import {
|
||||
CastButton,
|
||||
useCastDevice,
|
||||
@@ -9,14 +7,13 @@ import {
|
||||
useRemoteMediaClient,
|
||||
} from "react-native-google-cast";
|
||||
import GoogleCast from "react-native-google-cast";
|
||||
import { Text } from "./common/Text";
|
||||
|
||||
type Props = {
|
||||
item?: BaseItemDto | null;
|
||||
startTimeTicks?: number | null;
|
||||
};
|
||||
|
||||
export const Chromecast: React.FC<Props> = ({ item, startTimeTicks }) => {
|
||||
export const Chromecast: React.FC<Props> = () => {
|
||||
const client = useRemoteMediaClient();
|
||||
const castDevice = useCastDevice();
|
||||
const devices = useDevices();
|
||||
@@ -26,43 +23,12 @@ export const Chromecast: React.FC<Props> = ({ item, startTimeTicks }) => {
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
if (!discoveryManager) {
|
||||
console.log("No discoveryManager client");
|
||||
return;
|
||||
}
|
||||
|
||||
await discoveryManager.startDiscovery();
|
||||
|
||||
const started = await discoveryManager.isRunning();
|
||||
|
||||
console.log({
|
||||
devices,
|
||||
castDevice,
|
||||
sessionManager,
|
||||
});
|
||||
})();
|
||||
}, [client, devices, castDevice, sessionManager, discoveryManager]);
|
||||
|
||||
const cast = () => {
|
||||
if (!client) {
|
||||
console.log("No chromecast client");
|
||||
return;
|
||||
}
|
||||
|
||||
client.loadMedia({
|
||||
mediaInfo: {
|
||||
contentUrl:
|
||||
"https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/BigBuckBunny.mp4",
|
||||
contentType: "video/mp4",
|
||||
metadata: {
|
||||
type: item?.Type === "Episode" ? "tvShow" : "movie",
|
||||
title: item?.Name || "",
|
||||
subtitle: item?.Overview || "",
|
||||
},
|
||||
streamDuration: Math.floor((item?.RunTimeTicks || 0) / 10000),
|
||||
},
|
||||
startTime: Math.floor((startTimeTicks || 0) / 10000),
|
||||
});
|
||||
};
|
||||
|
||||
return <CastButton style={{ tintColor: "white", height: 48, width: 48 }} />;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user