feat: User profile Settings - allow external players from server when running in shell

Signed-off-by: Lachezar Lechev <lachezar@ambire.com>
This commit is contained in:
Lachezar Lechev 2025-02-10 11:07:13 +02:00
parent 2d17afc0f6
commit c58ea764aa
No known key found for this signature in database
GPG key ID: FDC9325CE311E8A4

View file

@ -3,11 +3,12 @@
const React = require('react'); const React = require('react');
const { useTranslation } = require('react-i18next'); const { useTranslation } = require('react-i18next');
const { useServices } = require('stremio/services'); const { useServices } = require('stremio/services');
const { CONSTANTS, usePlatform, interfaceLanguages, languageNames } = require('stremio/common'); const { CONSTANTS, usePlatform, useStreamingServer, interfaceLanguages, languageNames } = require('stremio/common');
const useProfileSettingsInputs = (profile) => { const useProfileSettingsInputs = (profile) => {
const { t } = useTranslation(); const { t } = useTranslation();
const { core } = useServices(); const { core, shell } = useServices();
const streamingServer = useStreamingServer();
const platform = usePlatform(); const platform = usePlatform();
// TODO combine those useMemo in one // TODO combine those useMemo in one
const interfaceLanguageSelect = React.useMemo(() => ({ const interfaceLanguageSelect = React.useMemo(() => ({
@ -213,7 +214,14 @@ const useProfileSettingsInputs = (profile) => {
}), [profile.settings]); }), [profile.settings]);
const playInExternalPlayerSelect = React.useMemo(() => ({ const playInExternalPlayerSelect = React.useMemo(() => ({
options: CONSTANTS.EXTERNAL_PLAYERS options: CONSTANTS.EXTERNAL_PLAYERS
.filter(({ platforms }) => platforms.includes(platform.name)) .filter(({ platforms, value }) => {
// FOR TESTING ONLY as there is no shell for linux
// let runningInShell = shell.active || true;
let runningInShell = shell.active;
let playbackDevicesInShell = runningInShell && (streamingServer.playbackDevices !== null && streamingServer.playbackDevices.type === 'Ready' && streamingServer.playbackDevices.content.find(({ id, type }) => type === 'external' && id === value));
return platforms.includes(platform.name) || playbackDevicesInShell;
})
.map(({ label, value }) => ({ .map(({ label, value }) => ({
value, value,
label: t(label), label: t(label),
@ -235,7 +243,7 @@ const useProfileSettingsInputs = (profile) => {
} }
}); });
} }
}), [profile.settings]); }), [profile.settings, streamingServer.playbackDevices]);
const nextVideoPopupDurationSelect = React.useMemo(() => ({ const nextVideoPopupDurationSelect = React.useMemo(() => ({
options: CONSTANTS.NEXT_VIDEO_POPUP_DURATIONS.map((duration) => ({ options: CONSTANTS.NEXT_VIDEO_POPUP_DURATIONS.map((duration) => ({
value: `${duration}`, value: `${duration}`,