aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-08-07 10:17:19 +0200
committerChocobozzz <me@florianbigard.com>2019-08-07 12:07:58 +0200
commitd1f21ebba640ccec21ca96496d0319f7511ac0b4 (patch)
tree2318cc823ac60f2646bf14cab0680697dd6a8348 /client/src
parent327b331889861a031500cb91f698e370f14e3153 (diff)
downloadPeerTube-d1f21ebba640ccec21ca96496d0319f7511ac0b4.tar.gz
PeerTube-d1f21ebba640ccec21ca96496d0319f7511ac0b4.tar.zst
PeerTube-d1f21ebba640ccec21ca96496d0319f7511ac0b4.zip
Fix control bar inactive timeout
Diffstat (limited to 'client/src')
-rw-r--r--client/src/assets/player/peertube-plugin.ts48
-rw-r--r--client/src/assets/player/videojs-components/settings-menu-button.ts4
2 files changed, 37 insertions, 15 deletions
diff --git a/client/src/assets/player/peertube-plugin.ts b/client/src/assets/player/peertube-plugin.ts
index dd9408c8e..9824c43b5 100644
--- a/client/src/assets/player/peertube-plugin.ts
+++ b/client/src/assets/player/peertube-plugin.ts
@@ -36,6 +36,10 @@ class PeerTubePlugin extends Plugin {
36 private userWatchingVideoInterval: any 36 private userWatchingVideoInterval: any
37 private lastResolutionChange: ResolutionUpdateData 37 private lastResolutionChange: ResolutionUpdateData
38 38
39 private menuOpened = false
40 private mouseInControlBar = false
41 private readonly savedInactivityTimeout: number
42
39 constructor (player: videojs.Player, options: PeerTubePluginOptions) { 43 constructor (player: videojs.Player, options: PeerTubePluginOptions) {
40 super(player, options) 44 super(player, options)
41 45
@@ -43,6 +47,8 @@ class PeerTubePlugin extends Plugin {
43 this.videoDuration = options.videoDuration 47 this.videoDuration = options.videoDuration
44 this.videoCaptions = options.videoCaptions 48 this.videoCaptions = options.videoCaptions
45 49
50 this.savedInactivityTimeout = player.options_.inactivityTimeout
51
46 if (options.autoplay === true) this.player.addClass('vjs-has-autoplay') 52 if (options.autoplay === true) this.player.addClass('vjs-has-autoplay')
47 53
48 this.player.on('autoplay-failure', () => { 54 this.player.on('autoplay-failure', () => {
@@ -124,6 +130,16 @@ class PeerTubePlugin extends Plugin {
124 if (this.userWatchingVideoInterval) clearInterval(this.userWatchingVideoInterval) 130 if (this.userWatchingVideoInterval) clearInterval(this.userWatchingVideoInterval)
125 } 131 }
126 132
133 onMenuOpen () {
134 this.menuOpened = false
135 this.alterInactivity()
136 }
137
138 onMenuClosed () {
139 this.menuOpened = true
140 this.alterInactivity()
141 }
142
127 private initializePlayer () { 143 private initializePlayer () {
128 if (isMobile()) this.player.addClass('vjs-is-mobile') 144 if (isMobile()) this.player.addClass('vjs-is-mobile')
129 145
@@ -131,7 +147,7 @@ class PeerTubePlugin extends Plugin {
131 147
132 this.initCaptions() 148 this.initCaptions()
133 149
134 this.alterInactivity() 150 this.listenControlBarMouse()
135 } 151 }
136 152
137 private runViewAdd () { 153 private runViewAdd () {
@@ -208,23 +224,25 @@ class PeerTubePlugin extends Plugin {
208 this.trigger('resolutionChange', data) 224 this.trigger('resolutionChange', data)
209 } 225 }
210 226
211 private alterInactivity () { 227 private listenControlBarMouse () {
212 let saveInactivityTimeout: number 228 this.player.controlBar.on('mouseenter', () => {
229 this.mouseInControlBar = true
230 this.alterInactivity()
231 })
213 232
214 const disableInactivity = () => { 233 this.player.controlBar.on('mouseleave', () => {
215 saveInactivityTimeout = this.player.options_.inactivityTimeout 234 this.mouseInControlBar = false
216 this.player.options_.inactivityTimeout = 0 235 this.alterInactivity()
217 } 236 })
218 const enableInactivity = () => { 237 }
219 this.player.options_.inactivityTimeout = saveInactivityTimeout
220 }
221 238
222 const settingsDialog = this.player.children_.find((c: any) => c.name_ === 'SettingsDialog') 239 private alterInactivity () {
240 if (this.menuOpened || this.mouseInControlBar) {
241 this.player.options_.inactivityTimeout = this.savedInactivityTimeout
242 return
243 }
223 244
224 this.player.controlBar.on('mouseenter', () => disableInactivity()) 245 this.player.options_.inactivityTimeout = 1
225 settingsDialog.on('mouseenter', () => disableInactivity())
226 this.player.controlBar.on('mouseleave', () => enableInactivity())
227 settingsDialog.on('mouseleave', () => enableInactivity())
228 } 246 }
229 247
230 private initCaptions () { 248 private initCaptions () {
diff --git a/client/src/assets/player/videojs-components/settings-menu-button.ts b/client/src/assets/player/videojs-components/settings-menu-button.ts
index 3e8b5fc94..b700f4be6 100644
--- a/client/src/assets/player/videojs-components/settings-menu-button.ts
+++ b/client/src/assets/player/videojs-components/settings-menu-button.ts
@@ -122,6 +122,8 @@ class SettingsButton extends Button {
122 } 122 }
123 123
124 showDialog () { 124 showDialog () {
125 this.player_.peertube().onMenuOpen()
126
125 this.menu.el_.style.opacity = '1' 127 this.menu.el_.style.opacity = '1'
126 this.dialog.show() 128 this.dialog.show()
127 129
@@ -129,6 +131,8 @@ class SettingsButton extends Button {
129 } 131 }
130 132
131 hideDialog () { 133 hideDialog () {
134 this.player_.peertube().onMenuClosed()
135
132 this.dialog.hide() 136 this.dialog.hide()
133 this.setDialogSize(this.getComponentSize(this.menu)) 137 this.setDialogSize(this.getComponentSize(this.menu))
134 this.menu.el_.style.opacity = '1' 138 this.menu.el_.style.opacity = '1'