VLC button support added

This commit is contained in:
Daniel Shleifman
2022-06-19 20:12:39 +03:00
parent 619949d25c
commit a0ba83c9d4
7 changed files with 63 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
{ {
"name": "", "name": "TorrServer",
"short_name": "TorrServer", "short_name": "TorrServer",
"icons": [ "icons": [
{ {

View File

@@ -28,6 +28,8 @@ const Table = memo(
// if files in list is more then 1 and no season text detected by ptt.parse, show full name // if files in list is more then 1 and no season text detected by ptt.parse, show full name
const shouldDisplayFullFileName = playableFileList.length > 1 && !fileHasEpisodeText const shouldDisplayFullFileName = playableFileList.length > 1 && !fileHasEpisodeText
const isVlcUsed = JSON.parse(localStorage.getItem('isVlcUsed')) ?? true
return !playableFileList?.length ? ( return !playableFileList?.length ? (
'No playable files in this torrent' 'No playable files in this torrent'
) : ( ) : (
@@ -133,11 +135,19 @@ const Table = memo(
{t('Preload')} {t('Preload')}
</Button> </Button>
{isVlcUsed ? (
<a style={{ textDecoration: 'none' }} href={`vlc://${link}`}>
<Button style={{ width: '100%' }} variant='outlined' color='primary' size='small'>
VLC
</Button>
</a>
) : (
<a style={{ textDecoration: 'none' }} href={link} target='_blank' rel='noreferrer'> <a style={{ textDecoration: 'none' }} href={link} target='_blank' rel='noreferrer'>
<Button style={{ width: '100%' }} variant='outlined' color='primary' size='small'> <Button style={{ width: '100%' }} variant='outlined' color='primary' size='small'>
{t('OpenLink')} {t('OpenLink')}
</Button> </Button>
</a> </a>
)}
<CopyToClipboard text={link}> <CopyToClipboard text={link}>
<Button variant='outlined' color='primary' size='small'> <Button variant='outlined' color='primary' size='small'>

View File

@@ -0,0 +1,20 @@
import { FormControlLabel, Switch } from '@material-ui/core'
import { useTranslation } from 'react-i18next'
import { SecondarySettingsContent, SettingSectionLabel } from './style'
export default function MobileAppSettings({ isVlcUsed, setIsVlcUsed }) {
const { t } = useTranslation()
return (
<SecondarySettingsContent>
<SettingSectionLabel>{t('SettingsDialog.MobileAppSettings')}</SettingSectionLabel>
<FormControlLabel
control={<Switch checked={isVlcUsed} onChange={() => setIsVlcUsed(prev => !prev)} color='secondary' />}
label={t('SettingsDialog.UseVLC')}
labelPlacement='start'
/>
</SecondarySettingsContent>
)
}

View File

@@ -12,12 +12,14 @@ import SwipeableViews from 'react-swipeable-views'
import CircularProgress from '@material-ui/core/CircularProgress' import CircularProgress from '@material-ui/core/CircularProgress'
import { StyledDialog } from 'style/CustomMaterialUiStyles' import { StyledDialog } from 'style/CustomMaterialUiStyles'
import useOnStandaloneAppOutsideClick from 'utils/useOnStandaloneAppOutsideClick' import useOnStandaloneAppOutsideClick from 'utils/useOnStandaloneAppOutsideClick'
import { isStandaloneApp } from 'utils/Utils'
import { SettingsHeader, FooterSection, Content } from './style' import { SettingsHeader, FooterSection, Content } from './style'
import defaultSettings from './defaultSettings' import defaultSettings from './defaultSettings'
import { a11yProps, TabPanel } from './tabComponents' import { a11yProps, TabPanel } from './tabComponents'
import PrimarySettingsComponent from './PrimarySettingsComponent' import PrimarySettingsComponent from './PrimarySettingsComponent'
import SecondarySettingsComponent from './SecondarySettingsComponent' import SecondarySettingsComponent from './SecondarySettingsComponent'
import MobileAppSettings from './MobileAppSettings'
export default function SettingsDialog({ handleClose }) { export default function SettingsDialog({ handleClose }) {
const { t } = useTranslation() const { t } = useTranslation()
@@ -30,6 +32,7 @@ export default function SettingsDialog({ handleClose }) {
const [cachePercentage, setCachePercentage] = useState(40) const [cachePercentage, setCachePercentage] = useState(40)
const [preloadCachePercentage, setPreloadCachePercentage] = useState(0) const [preloadCachePercentage, setPreloadCachePercentage] = useState(0)
const [isProMode, setIsProMode] = useState(JSON.parse(localStorage.getItem('isProMode')) || false) const [isProMode, setIsProMode] = useState(JSON.parse(localStorage.getItem('isProMode')) || false)
const [isVlcUsed, setIsVlcUsed] = useState(JSON.parse(localStorage.getItem('isVlcUsed')) ?? true)
useEffect(() => { useEffect(() => {
axios.post(settingsHost(), { action: 'get' }).then(({ data }) => { axios.post(settingsHost(), { action: 'get' }).then(({ data }) => {
@@ -46,6 +49,7 @@ export default function SettingsDialog({ handleClose }) {
sets.ReaderReadAHead = cachePercentage sets.ReaderReadAHead = cachePercentage
sets.PreloadCache = preloadCachePercentage sets.PreloadCache = preloadCachePercentage
axios.post(settingsHost(), { action: 'set', sets }) axios.post(settingsHost(), { action: 'set', sets })
localStorage.setItem('isVlcUsed', isVlcUsed)
} }
const inputForm = ({ target: { type, value, checked, id } }) => { const inputForm = ({ target: { type, value, checked, id } }) => {
@@ -124,6 +128,8 @@ export default function SettingsDialog({ handleClose }) {
} }
{...a11yProps(1)} {...a11yProps(1)}
/> />
{isStandaloneApp && <Tab label={t('SettingsDialog.Tabs.App')} {...a11yProps(2)} />}
</Tabs> </Tabs>
</AppBar> </AppBar>
@@ -153,6 +159,12 @@ export default function SettingsDialog({ handleClose }) {
<TabPanel value={selectedTab} index={1} dir={direction}> <TabPanel value={selectedTab} index={1} dir={direction}>
<SecondarySettingsComponent settings={settings} inputForm={inputForm} /> <SecondarySettingsComponent settings={settings} inputForm={inputForm} />
</TabPanel> </TabPanel>
{isStandaloneApp && (
<TabPanel value={selectedTab} index={2} dir={direction}>
<MobileAppSettings isVlcUsed={isVlcUsed} setIsVlcUsed={setIsVlcUsed} />
</TabPanel>
)}
</SwipeableViews> </SwipeableViews>
</> </>
) : ( ) : (

View File

@@ -88,6 +88,7 @@
"SettingsDialog": { "SettingsDialog": {
"AddRetrackers": "Add retrackers", "AddRetrackers": "Add retrackers",
"AdditionalSettings": "Additional Settings", "AdditionalSettings": "Additional Settings",
"MobileAppSettings": "Mobile app settings",
"CacheBeforeReaderDesc": "from cache will be saved before currently played frame", "CacheBeforeReaderDesc": "from cache will be saved before currently played frame",
"CacheAfterReaderDesc": "from cache will be loaded after currently played frame", "CacheAfterReaderDesc": "from cache will be loaded after currently played frame",
"CacheSize": "Cache Size", "CacheSize": "Cache Size",
@@ -125,8 +126,10 @@
"Tabs": { "Tabs": {
"Main": "Main", "Main": "Main",
"Additional": "Additional", "Additional": "Additional",
"AdditionalDisabled": "(enable PRO mode)" "AdditionalDisabled": "(enable PRO mode)",
} "App": "App"
},
"UseVLC": "Prompt to open video in VLC"
}, },
"Size": "Size", "Size": "Size",
"SpecialThanks": "Special Thanks", "SpecialThanks": "Special Thanks",

View File

@@ -88,6 +88,7 @@
"SettingsDialog": { "SettingsDialog": {
"AddRetrackers": "Добавлять", "AddRetrackers": "Добавлять",
"AdditionalSettings": "Дополнительные настройки", "AdditionalSettings": "Дополнительные настройки",
"MobileAppSettings": "Настройки моб. приложения",
"CacheBeforeReaderDesc": "от кеша будет оставаться позади воспроизводимого кадра", "CacheBeforeReaderDesc": "от кеша будет оставаться позади воспроизводимого кадра",
"CacheAfterReaderDesc": "кеша будет спереди от воспроизводимого кадра", "CacheAfterReaderDesc": "кеша будет спереди от воспроизводимого кадра",
"CacheSize": "Размер кеша", "CacheSize": "Размер кеша",
@@ -125,8 +126,10 @@
"Tabs": { "Tabs": {
"Main": "Основные", "Main": "Основные",
"Additional": "Дополнительные", "Additional": "Дополнительные",
"AdditionalDisabled": "(включите ПРО-режим)" "AdditionalDisabled": "(включите ПРО-режим)",
} "App": "Приложение"
},
"UseVLC": "Предлагать открыть видео в VLC"
}, },
"Size": "Размер", "Size": "Размер",
"SpecialThanks": "Отдельное спасибо", "SpecialThanks": "Отдельное спасибо",

View File

@@ -88,6 +88,7 @@
"SettingsDialog": { "SettingsDialog": {
"AddRetrackers": "Додавати", "AddRetrackers": "Додавати",
"AdditionalSettings": "Додаткові налаштування", "AdditionalSettings": "Додаткові налаштування",
"MobileAppSettings": "Установки моб. програми",
"CacheBeforeReaderDesc": "з кешу буде збережено до поточного відтворюваного кадру", "CacheBeforeReaderDesc": "з кешу буде збережено до поточного відтворюваного кадру",
"CacheAfterReaderDesc": "з кешу буде завантажено після поточно відтвореного кадру", "CacheAfterReaderDesc": "з кешу буде завантажено після поточно відтвореного кадру",
"CacheSize": "Размір кешу", "CacheSize": "Размір кешу",
@@ -125,8 +126,10 @@
"Tabs": { "Tabs": {
"Main": "Основні", "Main": "Основні",
"Additional": "Додаткові", "Additional": "Додаткові",
"AdditionalDisabled": "(включіть ПРО-режим)" "AdditionalDisabled": "(включіть ПРО-режим)",
} "App": "Додаток"
},
"UseVLC": "Пропонувати відкрити відео у VLC"
}, },
"Size": "Розмір", "Size": "Розмір",
"SpecialThanks": "Окрема подяка", "SpecialThanks": "Окрема подяка",