Add support for the 'defaultCustomArguments' external player mapping field (#1415)

* feat(store/utils): add support for the `defaultCustomArguments` external player mapping field
improve(store/utils): move custom arguments evaluation to the top in `openInExternalPlayer`
improve(components/external-player-settings): conditionally append the default custom arguments to the tooltip

Signed-off-by: Randshot <randshot@norealm.xyz>

* fix(components/external-player-settings): fix lint error
chore(components/external-player-settings): remove unnecessary console log

Signed-off-by: Randshot <randshot@norealm.xyz>

* chore(static/external-player-map): add new `defaultCustomArguments` field to vlc map

Signed-off-by: Randshot <randshot@norealm.xyz>
This commit is contained in:
kuhaku 2021-10-07 06:29:43 +00:00 committed by GitHub
parent dad3f2b8d6
commit 3cf18b9f2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 7 deletions

View File

@ -40,6 +40,18 @@ export default Vue.extend({
}, },
externalPlayerCustomArgs: function () { externalPlayerCustomArgs: function () {
return this.$store.getters.getExternalPlayerCustomArgs return this.$store.getters.getExternalPlayerCustomArgs
},
externalPlayerCustomArgsTooltip: function () {
const tooltip = this.$t('Tooltips.External Player Settings.Custom External Player Arguments')
const cmdArgs = this.$store.getters.getExternalPlayerCmdArguments[this.externalPlayer]
if (cmdArgs && typeof cmdArgs.defaultCustomArguments === 'string' && cmdArgs.defaultCustomArguments !== '') {
const defaultArgs = this.$t('Tooltips.External Player Settings.DefaultCustomArgumentsTemplate')
.replace('$', cmdArgs.defaultCustomArguments)
return `${tooltip} ${defaultArgs}`
}
return tooltip
} }
}, },
methods: { methods: {

View File

@ -44,7 +44,7 @@
:show-action-button="false" :show-action-button="false"
:show-label="true" :show-label="true"
:value="externalPlayerCustomArgs" :value="externalPlayerCustomArgs"
:tooltip="$t('Tooltips.External Player Settings.Custom External Player Arguments')" :tooltip="externalPlayerCustomArgsTooltip"
@input="updateExternalPlayerCustomArgs" @input="updateExternalPlayerCustomArgs"
/> />
</ft-flex-box> </ft-flex-box>

View File

@ -674,6 +674,16 @@ const actions = {
const ignoreWarnings = rootState.settings.externalPlayerIgnoreWarnings const ignoreWarnings = rootState.settings.externalPlayerIgnoreWarnings
const customArgs = rootState.settings.externalPlayerCustomArgs const customArgs = rootState.settings.externalPlayerCustomArgs
// Append custom user-defined arguments,
// or use the default ones specified for the external player.
if (typeof customArgs === 'string' && customArgs !== '') {
const custom = customArgs.split(';')
args.push(...custom)
} else if (typeof cmdArgs.defaultCustomArguments === 'string' && cmdArgs.defaultCustomArguments !== '') {
const defaultCustomArguments = cmdArgs.defaultCustomArguments.split(';')
args.push(...defaultCustomArguments)
}
if (payload.watchProgress > 0) { if (payload.watchProgress > 0) {
if (typeof cmdArgs.startOffset === 'string') { if (typeof cmdArgs.startOffset === 'string') {
args.push(`${cmdArgs.startOffset}${payload.watchProgress}`) args.push(`${cmdArgs.startOffset}${payload.watchProgress}`)
@ -776,12 +786,6 @@ const actions = {
} }
} }
// Append custom user-defined arguments
if (customArgs !== null) {
const custom = customArgs.split(';')
args.push(...custom)
}
const openingToast = payload.strings.OpeningTemplate const openingToast = payload.strings.OpeningTemplate
.replace('$', payload.playlistId === null || payload.playlistId === '' .replace('$', payload.playlistId === null || payload.playlistId === ''
? payload.strings.video ? payload.strings.video

View File

@ -9,6 +9,7 @@
"value": "mpv", "value": "mpv",
"cmdArguments": { "cmdArguments": {
"defaultExecutable": "mpv", "defaultExecutable": "mpv",
"defaultCustomArguments": null,
"supportsYtdlProtocol": true, "supportsYtdlProtocol": true,
"videoUrl": "", "videoUrl": "",
"playlistUrl": "", "playlistUrl": "",
@ -25,6 +26,7 @@
"value": "vlc", "value": "vlc",
"cmdArguments": { "cmdArguments": {
"defaultExecutable": "vlc", "defaultExecutable": "vlc",
"defaultCustomArguments": null,
"supportsYtdlProtocol": false, "supportsYtdlProtocol": false,
"videoUrl": "", "videoUrl": "",
"playlistUrl": null, "playlistUrl": null,

View File

@ -653,6 +653,8 @@ Tooltips:
the current action (e.g. reversing playlists, etc.). the current action (e.g. reversing playlists, etc.).
Custom External Player Arguments: Any custom command line arguments, separated by semicolons (';'), Custom External Player Arguments: Any custom command line arguments, separated by semicolons (';'),
you want to be passed to the external player. you want to be passed to the external player.
# $ is replaced with the default custom arguments for the current player, if defined.
DefaultCustomArgumentsTemplate: '(Default: ''$'')'
Subscription Settings: Subscription Settings:
Fetch Feeds from RSS: When enabled, FreeTube will use RSS instead of its default Fetch Feeds from RSS: When enabled, FreeTube will use RSS instead of its default
method for grabbing your subscription feed. RSS is faster and prevents IP blocking, method for grabbing your subscription feed. RSS is faster and prevents IP blocking,

View File

@ -724,6 +724,8 @@ Tooltips:
support the current action (e.g. reversing playlists, etc.). support the current action (e.g. reversing playlists, etc.).
Custom External Player Arguments: Any custom command line arguments, separated Custom External Player Arguments: Any custom command line arguments, separated
by semicolons (';'), you want to be passed to the external player. by semicolons (';'), you want to be passed to the external player.
# $ is replaced with the default custom arguments for the current player, if defined.
DefaultCustomArgumentsTemplate: '(Default: ''$'')'
Privacy Settings: Privacy Settings:
Remove Video Meta Files: When enabled, FreeTube automatically deletes meta files Remove Video Meta Files: When enabled, FreeTube automatically deletes meta files
created during video playback, when the watch page is closed. created during video playback, when the watch page is closed.