-import { VideoFile } from '../../../../shared'
-
-// videojs typings don't have some method we need
-const videojsUntyped = videojs as any
-const webtorrent = new WebTorrent({ dht: false })
-
-const MenuItem = videojsUntyped.getComponent('MenuItem')
-const ResolutionMenuItem = videojsUntyped.extend(MenuItem, {
- constructor: function (player: Player, options) {
- options.selectable = true
- MenuItem.call(this, player, options)
-
- const currentResolution = this.player_.getCurrentResolution()
- this.selected(this.options_.id === currentResolution)
- },
-
- handleClick: function (event) {
- MenuItem.prototype.handleClick.call(this, event)
- this.player_.updateResolution(this.options_.id)
- }
-})
-MenuItem.registerComponent('ResolutionMenuItem', ResolutionMenuItem)
-
-const MenuButton = videojsUntyped.getComponent('MenuButton')
-const ResolutionMenuButton = videojsUntyped.extend(MenuButton, {
- constructor: function (player, options) {
- this.label = document.createElement('span')
- options.label = 'Quality'
-
- MenuButton.call(this, player, options)
- this.el().setAttribute('aria-label', 'Quality')
- this.controlText('Quality')
-
- videojsUntyped.dom.addClass(this.label, 'vjs-resolution-button-label')
- this.el().appendChild(this.label)
-
- player.on('videoFileUpdate', videojs.bind(this, this.update))
- },
-
- createItems: function () {
- const menuItems = []
- for (const videoFile of this.player_.videoFiles) {
- menuItems.push(new ResolutionMenuItem(
- this.player_,
+import './settings-menu-button'
+import { PeertubePluginOptions, VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
+import {
+ getAverageBandwidth,
+ getStoredMute,
+ getStoredVolume,
+ saveAverageBandwidth,
+ saveMuteInStore,
+ saveVolumeInStore
+} from './utils'
+import minBy from 'lodash-es/minBy'
+import maxBy from 'lodash-es/maxBy'
+
+const webtorrent = new WebTorrent({
+ tracker: {
+ rtcConfig: {
+ iceServers: [