Resume video on peertube link click in embed
This commit is contained in:
parent
6b950ba5ee
commit
fc73684ada
|
@ -4,17 +4,37 @@ const Button: VideoJSComponentInterface = videojsUntyped.getComponent('Button')
|
||||||
class PeerTubeLinkButton extends Button {
|
class PeerTubeLinkButton extends Button {
|
||||||
|
|
||||||
createEl () {
|
createEl () {
|
||||||
return videojsUntyped.dom.createEl('a', {
|
return this.buildElement()
|
||||||
href: window.location.href.replace('embed', 'watch'),
|
}
|
||||||
innerHTML: 'PeerTube',
|
|
||||||
title: 'Go to the video page',
|
updateHref () {
|
||||||
className: 'vjs-peertube-link',
|
const currentTime = Math.floor(this.player().currentTime())
|
||||||
target: '_blank'
|
this.el().setAttribute('href', this.buildHref(currentTime))
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleClick () {
|
handleClick () {
|
||||||
this.player_.pause()
|
this.player_.pause()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private buildElement () {
|
||||||
|
const el = videojsUntyped.dom.createEl('a', {
|
||||||
|
href: this.buildHref(),
|
||||||
|
innerHTML: 'PeerTube',
|
||||||
|
title: 'Go to the video page',
|
||||||
|
className: 'vjs-peertube-link',
|
||||||
|
target: '_blank'
|
||||||
|
})
|
||||||
|
|
||||||
|
el.addEventListener('mouseenter', () => this.updateHref())
|
||||||
|
|
||||||
|
return el
|
||||||
|
}
|
||||||
|
|
||||||
|
private buildHref (time?: number) {
|
||||||
|
let href = window.location.href.replace('embed', 'watch')
|
||||||
|
if (time) href += '?start=' + time
|
||||||
|
|
||||||
|
return href
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Button.registerComponent('PeerTubeLinkButton', PeerTubeLinkButton)
|
Button.registerComponent('PeerTubeLinkButton', PeerTubeLinkButton)
|
||||||
|
|
Loading…
Reference in New Issue