import './upnext/upnext-plugin'
import './bezels/bezels-plugin'
import './peertube-plugin'
-import './videojs-components/next-video-button'
+import './videojs-components/next-previous-video-button'
import './videojs-components/p2p-info-button'
import './videojs-components/peertube-link-button'
import './videojs-components/peertube-load-progress-bar'
import './videojs-components/settings-panel'
import './videojs-components/settings-panel-child'
import './videojs-components/theater-button'
+import './playlist/playlist-plugin'
import videojs from 'video.js'
-import { isDefaultLocale } from '../../../../shared/models/i18n/i18n'
-import { VideoFile } from '../../../../shared/models/videos'
+import { isDefaultLocale } from '@shared/core-utils/i18n'
+import { VideoFile } from '@shared/models'
import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager'
import { segmentUrlBuilderFactory } from './p2p-media-loader/segment-url-builder'
import { segmentValidatorFactory } from './p2p-media-loader/segment-validator'
import { getStoredP2PEnabled } from './peertube-player-local-storage'
-import { P2PMediaLoaderPluginOptions, UserWatching, VideoJSCaption, VideoJSPluginOptions } from './peertube-videojs-typings'
+import {
+ NextPreviousVideoButtonOptions,
+ P2PMediaLoaderPluginOptions,
+ PlaylistPluginOptions,
+ UserWatching,
+ VideoJSCaption,
+ VideoJSPluginOptions
+} from './peertube-videojs-typings'
import { TranslationsManager } from './translations-manager'
import { buildVideoEmbed, buildVideoLink, copyToClipboard, getRtcConfig, isIOS, isSafari } from './utils'
onPlayerElementChange: (element: HTMLVideoElement) => void
autoplay: boolean
- nextVideo?: Function
+
+ nextVideo?: () => void
+ hasNextVideo?: () => boolean
+
+ previousVideo?: () => void
+ hasPreviousVideo?: () => boolean
+
+ playlist?: PlaylistPluginOptions
+
videoDuration: number
enableHotkeys: boolean
inactivityTimeout: number
}
}
+ if (commonOptions.playlist) {
+ plugins.playlist = commonOptions.playlist
+ }
+
if (commonOptions.enableHotkeys === true) {
PeertubePlayerManager.addHotkeysOptions(plugins)
}
captions: commonOptions.captions,
peertubeLink: commonOptions.peertubeLink,
theaterButton: commonOptions.theaterButton,
- nextVideo: commonOptions.nextVideo
+
+ nextVideo: commonOptions.nextVideo,
+ hasNextVideo: commonOptions.hasNextVideo,
+
+ previousVideo: commonOptions.previousVideo,
+ hasPreviousVideo: commonOptions.hasPreviousVideo
}) as any // FIXME: typings
}
}
}
const hlsjs = {
levelLabelHandler: (level: { height: number, width: number }) => {
- const file = p2pMediaLoaderOptions.videoFiles.find(f => f.resolution.id === level.height)
+ const resolution = Math.min(level.height || 0, level.width || 0)
+
+ const file = p2pMediaLoaderOptions.videoFiles.find(f => f.resolution.id === resolution)
+ if (!file) {
+ console.error('Cannot find video file for level %d.', level.height)
+ return level.height
+ }
let label = file.resolution.label
if (file.fps >= 50) label += file.fps
private static getControlBarChildren (mode: PlayerMode, options: {
peertubeLink: boolean
- theaterButton: boolean,
- captions: boolean,
+ theaterButton: boolean
+ captions: boolean
+
nextVideo?: Function
+ hasNextVideo?: () => boolean
+
+ previousVideo?: Function
+ hasPreviousVideo?: () => boolean
}) {
const settingEntries = []
const loadProgressBar = mode === 'webtorrent' ? 'peerTubeLoadProgressBar' : 'loadProgressBar'
if (options.captions === true) settingEntries.push('captionsButton')
settingEntries.push('resolutionMenuButton')
- const children = {
- 'playToggle': {}
+ const children = {}
+
+ if (options.previousVideo) {
+ const buttonOptions: NextPreviousVideoButtonOptions = {
+ type: 'previous',
+ handler: options.previousVideo,
+ isDisabled: () => {
+ if (!options.hasPreviousVideo) return false
+
+ return !options.hasPreviousVideo()
+ }
+ }
+
+ Object.assign(children, {
+ 'previousVideoButton': buttonOptions
+ })
}
+ Object.assign(children, { playToggle: {} })
+
if (options.nextVideo) {
- Object.assign(children, {
- 'nextVideoButton': {
- handler: options.nextVideo
+ const buttonOptions: NextPreviousVideoButtonOptions = {
+ type: 'next',
+ handler: options.nextVideo,
+ isDisabled: () => {
+ if (!options.hasNextVideo) return false
+
+ return !options.hasNextVideo()
}
+ }
+
+ Object.assign(children, {
+ 'nextVideoButton': buttonOptions
})
}