aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/resolution-menu-item.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-03-30 17:40:00 +0200
committerChocobozzz <me@florianbigard.com>2018-04-03 14:02:10 +0200
commitc6352f2c64f3c1ad54f8500f493587cdce3d33c9 (patch)
tree642a5b29b4d68ed8915e5e800232eab069303f79 /client/src/assets/player/resolution-menu-item.ts
parent6b9af1293621a81564296ead6f12f5e70eafbca2 (diff)
downloadPeerTube-c6352f2c64f3c1ad54f8500f493587cdce3d33c9.tar.gz
PeerTube-c6352f2c64f3c1ad54f8500f493587cdce3d33c9.tar.zst
PeerTube-c6352f2c64f3c1ad54f8500f493587cdce3d33c9.zip
Improve player
Add a settings dialog based on the work of Yanko Shterev (@yshterev): https://github.com/yshterev/videojs-settings-menu. Thanks!
Diffstat (limited to 'client/src/assets/player/resolution-menu-item.ts')
-rw-r--r--client/src/assets/player/resolution-menu-item.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/client/src/assets/player/resolution-menu-item.ts b/client/src/assets/player/resolution-menu-item.ts
new file mode 100644
index 000000000..95e0ed1f8
--- /dev/null
+++ b/client/src/assets/player/resolution-menu-item.ts
@@ -0,0 +1,31 @@
1import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
2
3const MenuItem: VideoJSComponentInterface = videojsUntyped.getComponent('MenuItem')
4class ResolutionMenuItem extends MenuItem {
5
6 constructor (player: videojs.Player, options) {
7 const currentResolutionId = player.peertube().getCurrentResolutionId()
8 options.selectable = true
9 options.selected = options.id === currentResolutionId
10
11 super(player, options)
12
13 this.label = options.label
14 this.id = options.id
15
16 player.peertube().on('videoFileUpdate', () => this.update())
17 }
18
19 handleClick (event) {
20 super.handleClick(event)
21
22 this.player_.peertube().updateResolution(this.id)
23 }
24
25 update () {
26 this.selected(this.player_.peertube().getCurrentResolutionId() === this.id)
27 }
28}
29MenuItem.registerComponent('ResolutionMenuItem', ResolutionMenuItem)
30
31export { ResolutionMenuItem }