aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-05-28 11:35:18 +0200
committerChocobozzz <me@florianbigard.com>2018-05-28 11:36:29 +0200
commitfc73684adad4fdc6bb8a196bd54ef8ecec4e7391 (patch)
tree65ad485a34e3e3e0733320cb6be58aa5f6ae01c4
parent6b950ba5eeb68981025a94bed3b90f0cbb201935 (diff)
downloadPeerTube-fc73684adad4fdc6bb8a196bd54ef8ecec4e7391.tar.gz
PeerTube-fc73684adad4fdc6bb8a196bd54ef8ecec4e7391.tar.zst
PeerTube-fc73684adad4fdc6bb8a196bd54ef8ecec4e7391.zip
Resume video on peertube link click in embed
-rw-r--r--client/src/assets/player/peertube-link-button.ts28
1 files changed, 24 insertions, 4 deletions
diff --git a/client/src/assets/player/peertube-link-button.ts b/client/src/assets/player/peertube-link-button.ts
index 6ead78c00..a47adc2db 100644
--- a/client/src/assets/player/peertube-link-button.ts
+++ b/client/src/assets/player/peertube-link-button.ts
@@ -4,17 +4,37 @@ const Button: VideoJSComponentInterface = videojsUntyped.getComponent('Button')
4class PeerTubeLinkButton extends Button { 4class PeerTubeLinkButton extends Button {
5 5
6 createEl () { 6 createEl () {
7 return videojsUntyped.dom.createEl('a', { 7 return this.buildElement()
8 href: window.location.href.replace('embed', 'watch'), 8 }
9
10 updateHref () {
11 const currentTime = Math.floor(this.player().currentTime())
12 this.el().setAttribute('href', this.buildHref(currentTime))
13 }
14
15 handleClick () {
16 this.player_.pause()
17 }
18
19 private buildElement () {
20 const el = videojsUntyped.dom.createEl('a', {
21 href: this.buildHref(),
9 innerHTML: 'PeerTube', 22 innerHTML: 'PeerTube',
10 title: 'Go to the video page', 23 title: 'Go to the video page',
11 className: 'vjs-peertube-link', 24 className: 'vjs-peertube-link',
12 target: '_blank' 25 target: '_blank'
13 }) 26 })
27
28 el.addEventListener('mouseenter', () => this.updateHref())
29
30 return el
14 } 31 }
15 32
16 handleClick () { 33 private buildHref (time?: number) {
17 this.player_.pause() 34 let href = window.location.href.replace('embed', 'watch')
35 if (time) href += '?start=' + time
36
37 return href
18 } 38 }
19} 39}
20Button.registerComponent('PeerTubeLinkButton', PeerTubeLinkButton) 40Button.registerComponent('PeerTubeLinkButton', PeerTubeLinkButton)