Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP : feat: 6167 Add autoplay setting in the admin settings section #6788

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,18 @@ <h2 i18n>NEW USERS</h2>
</ng-container>
</ng-container>
</div>

<div class="form-group">
<my-peertube-checkbox
inputName="userPlaybackAutoStart" formControlName="playbackAutoStart"
i18n-labelText labelText="Enable playback automatic start by default for new users"
>
<ng-container ngProjectAs="description">
<span i18n>Video playback starts automatically when opening a video (can be overridden by user's settings)</span>
</ng-container>
</my-peertube-checkbox>
</div>

</ng-container>

</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
}
},
videoQuota: USER_VIDEO_QUOTA_VALIDATOR,
videoQuotaDaily: USER_VIDEO_QUOTA_DAILY_VALIDATOR
videoQuotaDaily: USER_VIDEO_QUOTA_DAILY_VALIDATOR,
playbackAutoStart: null
},
videoChannels: {
maxPerUser: MAX_VIDEO_CHANNELS_PER_USER_VALIDATOR
Expand Down
3 changes: 2 additions & 1 deletion client/src/app/core/users/user-local-storage.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,15 @@ export class UserLocalStorageService {

const defaultNSFWPolicy = htmlConfig.instance.defaultNSFWPolicy
const defaultP2PEnabled = htmlConfig.defaults.p2p.webapp.enabled
const defaultPlaybackAutoStart = htmlConfig.user.playbackAutoStart

return {
nsfwPolicy: this.localStorageService.getItem<NSFWPolicyType>(UserLocalStorageKeys.NSFW_POLICY) || defaultNSFWPolicy,
p2pEnabled: getBoolOrDefault(this.localStorageService.getItem(UserLocalStorageKeys.P2P_ENABLED), defaultP2PEnabled),
theme: this.localStorageService.getItem(UserLocalStorageKeys.THEME) || 'instance-default',
videoLanguages,

autoPlayVideo: getBoolOrDefault(this.localStorageService.getItem(UserLocalStorageKeys.AUTO_PLAY_VIDEO), true),
autoPlayVideo: getBoolOrDefault(this.localStorageService.getItem(UserLocalStorageKeys.AUTO_PLAY_VIDEO), defaultPlaybackAutoStart),
autoPlayNextVideo: getBoolOrDefault(this.localStorageService.getItem(UserLocalStorageKeys.AUTO_PLAY_NEXT_VIDEO), false),
autoPlayNextVideoPlaylist: getBoolOrDefault(this.localStorageService.getItem(UserLocalStorageKeys.AUTO_PLAY_VIDEO_PLAYLIST), true)
}
Expand Down
3,713 changes: 1,828 additions & 1,885 deletions client/src/locale/angular.ar.xlf

Large diffs are not rendered by default.

3,341 changes: 1,126 additions & 2,215 deletions client/src/locale/angular.ca-ES.xlf

Large diffs are not rendered by default.

2,848 changes: 850 additions & 1,998 deletions client/src/locale/angular.cs-CZ.xlf

Large diffs are not rendered by default.

6,405 changes: 3,204 additions & 3,201 deletions client/src/locale/angular.da-DK.xlf

Large diffs are not rendered by default.

4,507 changes: 2,229 additions & 2,278 deletions client/src/locale/angular.de-DE.xlf

Large diffs are not rendered by default.

5,961 changes: 2,982 additions & 2,979 deletions client/src/locale/angular.el-GR.xlf

Large diffs are not rendered by default.

6,571 changes: 3,287 additions & 3,284 deletions client/src/locale/angular.en-GB.xlf

Large diffs are not rendered by default.

6,349 changes: 3,176 additions & 3,173 deletions client/src/locale/angular.en-US.xlf

Large diffs are not rendered by default.

3,097 changes: 996 additions & 2,101 deletions client/src/locale/angular.eo.xlf

Large diffs are not rendered by default.

4,509 changes: 2,230 additions & 2,279 deletions client/src/locale/angular.es-ES.xlf

Large diffs are not rendered by default.

2,873 changes: 872 additions & 2,001 deletions client/src/locale/angular.eu-ES.xlf

Large diffs are not rendered by default.

4,537 changes: 2,244 additions & 2,293 deletions client/src/locale/angular.fa-IR.xlf

Large diffs are not rendered by default.

3,545 changes: 1,091 additions & 2,454 deletions client/src/locale/angular.fi-FI.xlf

Large diffs are not rendered by default.

3,963 changes: 1,194 additions & 2,769 deletions client/src/locale/angular.fr-FR.xlf

Large diffs are not rendered by default.

5,055 changes: 2,529 additions & 2,526 deletions client/src/locale/angular.gd.xlf

Large diffs are not rendered by default.

2,892 changes: 860 additions & 2,032 deletions client/src/locale/angular.gl-ES.xlf

Large diffs are not rendered by default.

2,945 changes: 880 additions & 2,065 deletions client/src/locale/angular.hr.xlf

Large diffs are not rendered by default.

3,051 changes: 947 additions & 2,104 deletions client/src/locale/angular.hu-HU.xlf

Large diffs are not rendered by default.

3,094 changes: 965 additions & 2,129 deletions client/src/locale/angular.is.xlf

Large diffs are not rendered by default.

4,537 changes: 2,244 additions & 2,293 deletions client/src/locale/angular.it-IT.xlf

Large diffs are not rendered by default.

2,974 changes: 879 additions & 2,095 deletions client/src/locale/angular.ja-JP.xlf

Large diffs are not rendered by default.

6,565 changes: 3,284 additions & 3,281 deletions client/src/locale/angular.jbo.xlf

Large diffs are not rendered by default.

5,643 changes: 2,823 additions & 2,820 deletions client/src/locale/angular.kab.xlf

Large diffs are not rendered by default.

6,029 changes: 3,016 additions & 3,013 deletions client/src/locale/angular.ko-KR.xlf

Large diffs are not rendered by default.

3,943 changes: 1,943 additions & 2,000 deletions client/src/locale/angular.lt-LT.xlf

Large diffs are not rendered by default.

4,633 changes: 2,292 additions & 2,341 deletions client/src/locale/angular.nb-NO.xlf

Large diffs are not rendered by default.

5,067 changes: 2,535 additions & 2,532 deletions client/src/locale/angular.nl-NL.xlf

Large diffs are not rendered by default.

6,027 changes: 3,015 additions & 3,012 deletions client/src/locale/angular.nn.xlf

Large diffs are not rendered by default.

5,261 changes: 2,632 additions & 2,629 deletions client/src/locale/angular.oc.xlf

Large diffs are not rendered by default.

4,539 changes: 2,245 additions & 2,294 deletions client/src/locale/angular.pl-PL.xlf

Large diffs are not rendered by default.

1,837 changes: 847 additions & 990 deletions client/src/locale/angular.pt-BR.xlf

Large diffs are not rendered by default.

5,361 changes: 3,560 additions & 1,801 deletions client/src/locale/angular.pt-PT.xlf

Large diffs are not rendered by default.

2,970 changes: 877 additions & 2,093 deletions client/src/locale/angular.ru-RU.xlf

Large diffs are not rendered by default.

2,999 changes: 965 additions & 2,034 deletions client/src/locale/angular.sk-SK.xlf

Large diffs are not rendered by default.

4,389 changes: 1,413 additions & 2,976 deletions client/src/locale/angular.sl-SI.xlf

Large diffs are not rendered by default.

3,423 changes: 994 additions & 2,429 deletions client/src/locale/angular.sv-SE.xlf

Large diffs are not rendered by default.

6,565 changes: 3,284 additions & 3,281 deletions client/src/locale/angular.ta.xlf

Large diffs are not rendered by default.

3,817 changes: 1,880 additions & 1,937 deletions client/src/locale/angular.th-TH.xlf

Large diffs are not rendered by default.

6,067 changes: 3,035 additions & 3,032 deletions client/src/locale/angular.tok.xlf

Large diffs are not rendered by default.

3,725 changes: 1,834 additions & 1,891 deletions client/src/locale/angular.tr-TR.xlf

Large diffs are not rendered by default.

4,491 changes: 2,221 additions & 2,270 deletions client/src/locale/angular.uk-UA.xlf

Large diffs are not rendered by default.

4,493 changes: 2,222 additions & 2,271 deletions client/src/locale/angular.vi-VN.xlf

Large diffs are not rendered by default.

552 changes: 288 additions & 264 deletions client/src/locale/angular.xlf

Large diffs are not rendered by default.

3,000 changes: 892 additions & 2,108 deletions client/src/locale/angular.zh-Hans-CN.xlf

Large diffs are not rendered by default.

2,962 changes: 873 additions & 2,089 deletions client/src/locale/angular.zh-Hant-TW.xlf

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,9 @@ user:

default_channel_name: 'Main $1 channel' # The placeholder $1 is used to represent the user's username

# By default, playback starts automatically when opening a video for a new user or when anonymous
playback_auto_start: true

video_channels:
max_per_user: 20 # Allows each user to create up to 20 video channels.

Expand Down
1 change: 1 addition & 0 deletions packages/models/src/server/custom-config.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export interface CustomConfig {
videoQuota: number
videoQuotaDaily: number
defaultChannelName: string
playbackAutoStart: boolean
}

videoChannels: {
Expand Down
1 change: 1 addition & 0 deletions packages/models/src/server/server-config.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ export interface ServerConfig {
user: {
videoQuota: number
videoQuotaDaily: number
playbackAutoStart: boolean
}

videoChannels: {
Expand Down
5 changes: 4 additions & 1 deletion packages/tests/src/api/server/config-defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ describe('Test config defaults', function () {

expect(config.user.videoQuota).to.equal(-1)
expect(config.user.videoQuotaDaily).to.equal(-1)
expect(config.user.playbackAutoStart).to.equal(true)

const user1Token = await server.users.generateUserAndToken('user1')
const user1 = await server.users.getMyInfo({ token: user1Token })
Expand Down Expand Up @@ -263,7 +264,8 @@ describe('Test config defaults', function () {
}
},
videoQuota : 5242881,
videoQuotaDaily: 318742
videoQuotaDaily: 318742,
playbackAutoStart: false
},
signup: {
enabled: true,
Expand All @@ -285,6 +287,7 @@ describe('Test config defaults', function () {
expect(user.videosHistoryEnabled).to.be.false
expect(user.videoQuota).to.equal(5242881)
expect(user.videoQuotaDaily).to.equal(318742)
expect(user.autoPlayVideo).to.equal(false)
}
})

Expand Down
3 changes: 2 additions & 1 deletion packages/tests/src/api/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ function buildNewCustomConfig (server: PeerTubeServer): CustomConfig {
},
videoQuota: 5242881,
videoQuotaDaily: 318742,
defaultChannelName: 'Main $1 channel'
defaultChannelName: 'Main $1 channel',
playbackAutoStart: true
},
videoChannels: {
maxPerUser: 24
Expand Down
3 changes: 2 additions & 1 deletion server/core/controllers/api/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ function customConfig (): CustomConfig {
},
videoQuota: CONFIG.USER.VIDEO_QUOTA,
videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY,
defaultChannelName: CONFIG.USER.DEFAULT_CHANNEL_NAME
defaultChannelName: CONFIG.USER.DEFAULT_CHANNEL_NAME,
playbackAutoStart: CONFIG.USER.PLAYBACK_AUTO_START
},
videoChannels: {
maxPerUser: CONFIG.VIDEO_CHANNELS.MAX_PER_USER
Expand Down
2 changes: 1 addition & 1 deletion server/core/initializers/checker-before-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function checkMissedConfig () {
'open_telemetry.metrics.prometheus_exporter.hostname', 'open_telemetry.metrics.prometheus_exporter.port',
'open_telemetry.tracing.enabled', 'open_telemetry.tracing.jaeger_exporter.endpoint',
'open_telemetry.metrics.http_request_duration.enabled',
'user.history.videos.enabled', 'user.video_quota', 'user.video_quota_daily',
'user.history.videos.enabled', 'user.video_quota', 'user.video_quota_daily', 'user.playback_auto_start',
'video_channels.max_per_user',
'csp.enabled', 'csp.report_only', 'csp.report_uri',
'security.frameguard.enabled', 'security.powered_by_header.enabled',
Expand Down
3 changes: 2 additions & 1 deletion server/core/initializers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ const CONFIG = {
},
get VIDEO_QUOTA () { return parseBytes(config.get<number>('user.video_quota')) },
get VIDEO_QUOTA_DAILY () { return parseBytes(config.get<number>('user.video_quota_daily')) },
get DEFAULT_CHANNEL_NAME () { return config.get<string>('user.default_channel_name') }
get DEFAULT_CHANNEL_NAME () { return config.get<string>('user.default_channel_name') },
get PLAYBACK_AUTO_START () { return config.has('user.playback_auto_start') ? config.get<boolean>('user.playback_auto_start') : true }
},
VIDEO_CHANNELS: {
get MAX_PER_USER () { return config.get<number>('video_channels.max_per_user') }
Expand Down
3 changes: 2 additions & 1 deletion server/core/lib/server-config-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ class ServerConfigManager {
},
user: {
videoQuota: CONFIG.USER.VIDEO_QUOTA,
videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY
videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY,
playbackAutoStart: CONFIG.USER.PLAYBACK_AUTO_START
},
videoChannels: {
maxPerUser: CONFIG.VIDEO_CHANNELS.MAX_PER_USER
Expand Down
2 changes: 1 addition & 1 deletion server/core/lib/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function buildUser (options: {
p2pEnabled: CONFIG.DEFAULTS.P2P.WEBAPP.ENABLED,
videosHistoryEnabled: CONFIG.USER.HISTORY.VIDEOS.ENABLED,

autoPlayVideo: true,
autoPlayVideo: CONFIG.USER.PLAYBACK_AUTO_START,

role,
emailVerified,
Expand Down