diff options
author | Chocobozzz <me@florianbigard.com> | 2022-11-15 11:57:49 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-11-15 11:57:49 +0100 |
commit | 59a643aa5cf6775d27dfcc147b19c4537292d53c (patch) | |
tree | 74bc87e2f0f5581306c8ea9dd1f8acf05833a74a /client/src/assets/player | |
parent | c2419476302b20e9fe3708d7a0a889ae18c95c1b (diff) | |
download | PeerTube-59a643aa5cf6775d27dfcc147b19c4537292d53c.tar.gz PeerTube-59a643aa5cf6775d27dfcc147b19c4537292d53c.tar.zst PeerTube-59a643aa5cf6775d27dfcc147b19c4537292d53c.zip |
Force autoplay when live starts
Using the mute
Diffstat (limited to 'client/src/assets/player')
5 files changed, 13 insertions, 7 deletions
diff --git a/client/src/assets/player/shared/manager-options/manager-options-builder.ts b/client/src/assets/player/shared/manager-options/manager-options-builder.ts index 2d96c9410..4d227eb2a 100644 --- a/client/src/assets/player/shared/manager-options/manager-options-builder.ts +++ b/client/src/assets/player/shared/manager-options/manager-options-builder.ts | |||
@@ -105,10 +105,12 @@ export class ManagerOptionsBuilder { | |||
105 | Object.assign(videojsOptions, { language: commonOptions.language }) | 105 | Object.assign(videojsOptions, { language: commonOptions.language }) |
106 | } | 106 | } |
107 | 107 | ||
108 | console.log(videojsOptions) | ||
109 | |||
108 | return videojsOptions | 110 | return videojsOptions |
109 | } | 111 | } |
110 | 112 | ||
111 | private getAutoPlayValue (autoplay: any, alreadyPlayed: boolean) { | 113 | private getAutoPlayValue (autoplay: videojs.Autoplay, alreadyPlayed: boolean) { |
112 | if (autoplay !== true) return autoplay | 114 | if (autoplay !== true) return autoplay |
113 | 115 | ||
114 | // On first play, disable autoplay to avoid issues | 116 | // On first play, disable autoplay to avoid issues |
@@ -117,7 +119,9 @@ export class ManagerOptionsBuilder { | |||
117 | return alreadyPlayed ? 'play' : false | 119 | return alreadyPlayed ? 'play' : false |
118 | } | 120 | } |
119 | 121 | ||
120 | return 'play' | 122 | return this.options.common.forceAutoplay |
123 | ? 'any' | ||
124 | : 'play' | ||
121 | } | 125 | } |
122 | 126 | ||
123 | getContextMenuOptions (player: videojs.Player, commonOptions: CommonOptions) { | 127 | getContextMenuOptions (player: videojs.Player, commonOptions: CommonOptions) { |
diff --git a/client/src/assets/player/shared/peertube/peertube-plugin.ts b/client/src/assets/player/shared/peertube/peertube-plugin.ts index 56de66998..ec8fbb320 100644 --- a/client/src/assets/player/shared/peertube/peertube-plugin.ts +++ b/client/src/assets/player/shared/peertube/peertube-plugin.ts | |||
@@ -52,7 +52,7 @@ class PeerTubePlugin extends Plugin { | |||
52 | this.videoCaptions = options.videoCaptions | 52 | this.videoCaptions = options.videoCaptions |
53 | this.initialInactivityTimeout = this.player.options_.inactivityTimeout | 53 | this.initialInactivityTimeout = this.player.options_.inactivityTimeout |
54 | 54 | ||
55 | if (options.autoplay) this.player.addClass('vjs-has-autoplay') | 55 | if (options.autoplay !== false) this.player.addClass('vjs-has-autoplay') |
56 | 56 | ||
57 | this.player.on('autoplay-failure', () => { | 57 | this.player.on('autoplay-failure', () => { |
58 | this.player.removeClass('vjs-has-autoplay') | 58 | this.player.removeClass('vjs-has-autoplay') |
diff --git a/client/src/assets/player/shared/webtorrent/webtorrent-plugin.ts b/client/src/assets/player/shared/webtorrent/webtorrent-plugin.ts index 658b7c867..46d009410 100644 --- a/client/src/assets/player/shared/webtorrent/webtorrent-plugin.ts +++ b/client/src/assets/player/shared/webtorrent/webtorrent-plugin.ts | |||
@@ -25,7 +25,7 @@ class WebTorrentPlugin extends Plugin { | |||
25 | 25 | ||
26 | private readonly playerElement: HTMLVideoElement | 26 | private readonly playerElement: HTMLVideoElement |
27 | 27 | ||
28 | private readonly autoplay: boolean = false | 28 | private readonly autoplay: boolean | string = false |
29 | private readonly startTime: number = 0 | 29 | private readonly startTime: number = 0 |
30 | private readonly savePlayerSrcFunction: videojs.Player['src'] | 30 | private readonly savePlayerSrcFunction: videojs.Player['src'] |
31 | private readonly videoDuration: number | 31 | private readonly videoDuration: number |
@@ -449,7 +449,7 @@ class WebTorrentPlugin extends Plugin { | |||
449 | return | 449 | return |
450 | } | 450 | } |
451 | 451 | ||
452 | if (this.autoplay) { | 452 | if (this.autoplay !== false) { |
453 | this.player.posterImage.hide() | 453 | this.player.posterImage.hide() |
454 | 454 | ||
455 | return this.updateVideoFile(undefined, { forcePlay: true, seek: this.startTime }) | 455 | return this.updateVideoFile(undefined, { forcePlay: true, seek: this.startTime }) |
diff --git a/client/src/assets/player/types/manager-options.ts b/client/src/assets/player/types/manager-options.ts index 9da8fedf8..3057a5adb 100644 --- a/client/src/assets/player/types/manager-options.ts +++ b/client/src/assets/player/types/manager-options.ts | |||
@@ -36,6 +36,8 @@ export interface CommonOptions extends CustomizationOptions { | |||
36 | onPlayerElementChange: (element: HTMLVideoElement) => void | 36 | onPlayerElementChange: (element: HTMLVideoElement) => void |
37 | 37 | ||
38 | autoplay: boolean | 38 | autoplay: boolean |
39 | forceAutoplay: boolean | ||
40 | |||
39 | p2pEnabled: boolean | 41 | p2pEnabled: boolean |
40 | 42 | ||
41 | nextVideo?: () => void | 43 | nextVideo?: () => void |
diff --git a/client/src/assets/player/types/peertube-videojs-typings.ts b/client/src/assets/player/types/peertube-videojs-typings.ts index f02673a66..3d9d5270e 100644 --- a/client/src/assets/player/types/peertube-videojs-typings.ts +++ b/client/src/assets/player/types/peertube-videojs-typings.ts | |||
@@ -91,7 +91,7 @@ type VideoJSCaption = { | |||
91 | type PeerTubePluginOptions = { | 91 | type PeerTubePluginOptions = { |
92 | mode: PlayerMode | 92 | mode: PlayerMode |
93 | 93 | ||
94 | autoplay: boolean | 94 | autoplay: videojs.Autoplay |
95 | videoDuration: number | 95 | videoDuration: number |
96 | 96 | ||
97 | videoViewUrl: string | 97 | videoViewUrl: string |
@@ -143,7 +143,7 @@ type PeerTubeP2PInfoButtonOptions = { | |||
143 | type WebtorrentPluginOptions = { | 143 | type WebtorrentPluginOptions = { |
144 | playerElement: HTMLVideoElement | 144 | playerElement: HTMLVideoElement |
145 | 145 | ||
146 | autoplay: boolean | 146 | autoplay: videojs.Autoplay |
147 | videoDuration: number | 147 | videoDuration: number |
148 | 148 | ||
149 | videoFiles: VideoFile[] | 149 | videoFiles: VideoFile[] |