// Author: Yanko Shterev
// Thanks https://github.com/yshterev/videojs-settings-menu
+// FIXME: something weird with our path definition in tsconfig and typings
+// @ts-ignore
import * as videojs from 'video.js'
+
import { toTitleCase } from './utils'
import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
class SettingsMenuItem extends MenuItem {
- constructor (player: videojs.Player, options, entry: string, menuButton: VideoJSComponentInterface) {
+ constructor (player: videojs.Player, options: any, entry: string, menuButton: VideoJSComponentInterface) {
super(player, options)
this.settingsButton = menuButton
// Voodoo magic for IOS
setTimeout(() => {
this.build()
+
+ // Update on rate change
+ player.on('ratechange', this.submenuClickHandler)
+
+ if (subMenuName === 'CaptionsButton') {
+ // Hack to regenerate captions on HTTP fallback
+ player.on('captionsChanged', () => {
+ setTimeout(() => {
+ this.settingsSubMenuEl_.innerHTML = ''
+ this.settingsSubMenuEl_.appendChild(this.subMenu.menu.el_)
+ this.update()
+ this.bindClickEvents()
+
+ }, 0)
+ })
+ }
+
this.reset()
}, 0)
})
this.transitionEndHandler = this.onTransitionEnd.bind(this)
}
- onSubmenuClick (event) {
+ onSubmenuClick (event: any) {
let target = null
if (event.type === 'tap') {
target = event.currentTarget
}
- if (target.classList.contains('vjs-back-button')) {
+ if (target && target.classList.contains('vjs-back-button')) {
this.loadMainMenu()
return
}
*
* @method PrefixedEvent
*/
- PrefixedEvent (element, type, callback, action = 'addEvent') {
+ PrefixedEvent (element: any, type: any, callback: any, action = 'addEvent') {
let prefix = ['webkit', 'moz', 'MS', 'o', '']
for (let p = 0; p < prefix.length; p++) {
}
}
- onTransitionEnd (event) {
+ onTransitionEnd (event: any) {
if (event.propertyName !== 'margin-right') {
return
}
)
}
- update (event?: Event) {
- let target = null
+ update (event?: any) {
+ let target: HTMLElement = null
let subMenu = this.subMenu.name()
if (event && event.type === 'tap') {