Reorganize player files

This commit is contained in:
Chocobozzz 2022-03-14 14:28:20 +01:00
parent 9597920ee3
commit 57d6503286
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
72 changed files with 267 additions and 102 deletions

View File

@ -1,6 +1,5 @@
import { SortMeta } from 'primeng/api'
import { switchMap } from 'rxjs/operators'
import { buildVideoOrPlaylistEmbed } from 'src/assets/player/utils'
import { environment } from 'src/environments/environment'
import { Component, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
@ -8,6 +7,7 @@ import { ConfirmService, MarkdownService, Notifier, RestPagination, RestTable, S
import { AdvancedInputFilter } from '@app/shared/shared-forms'
import { DropdownAction, VideoService } from '@app/shared/shared-main'
import { VideoBlockService } from '@app/shared/shared-moderation'
import { buildVideoOrPlaylistEmbed } from '@root-helpers/video'
import { buildVideoEmbedLink, decorateVideoLink } from '@shared/core-utils'
import { VideoBlacklist, VideoBlacklistType } from '@shared/models'

View File

@ -1,6 +1,6 @@
import { truncate } from 'lodash-es'
import { UploadState, UploadxOptions, UploadxService } from 'ngx-uploadx'
import { isIOS } from 'src/assets/player/utils'
import { isIOS } from '@root-helpers/web-browser'
import { HttpErrorResponse, HttpEventType, HttpHeaders } from '@angular/common/http'
import { AfterViewInit, Component, ElementRef, EventEmitter, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'
import { Router } from '@angular/router'

View File

@ -1,8 +1,8 @@
import { Component, Input, OnInit } from '@angular/core'
import { ServerService, User, UserService } from '@app/core'
import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
import { isP2PEnabled } from '@root-helpers/video'
import { HTMLServerConfig, Video } from '@shared/models'
import { isP2PEnabled } from '../../../../../assets/player/utils'
@Component({
selector: 'my-privacy-concerns',

View File

@ -1,6 +1,6 @@
import { Hotkey, HotkeysService } from 'angular2-hotkeys'
import { forkJoin, map, Observable, of, Subscription, switchMap } from 'rxjs'
import { isP2PEnabled } from 'src/assets/player/utils'
import { VideoJsPlayer } from 'video.js'
import { PlatformLocation } from '@angular/common'
import { Component, ElementRef, Inject, LOCALE_ID, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
@ -24,6 +24,7 @@ import { Video, VideoCaptionService, VideoDetails, VideoService } from '@app/sha
import { SubscribeButtonComponent } from '@app/shared/shared-user-subscription'
import { LiveVideoService } from '@app/shared/shared-video-live'
import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist'
import { isP2PEnabled } from '@root-helpers/video'
import { timeToInt } from '@shared/core-utils'
import {
HTMLServerConfig,
@ -58,7 +59,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
@ViewChild('videoWatchPlaylist', { static: true }) videoWatchPlaylist: VideoWatchPlaylistComponent
@ViewChild('subscribeButton') subscribeButton: SubscribeButtonComponent
player: any
player: VideoJsPlayer
playerElement: HTMLVideoElement
playerPlaceholderImgSrc: string
theaterEnabled = false
@ -418,8 +419,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
this.zone.runOutsideAngular(async () => {
this.player = await PeertubePlayerManager.initialize(playerMode, playerOptions, player => this.player = player)
this.player.on('customError', ({ err }: { err: any }) => {
this.zone.run(() => this.handleGlobalError(err))
this.player.on('customError', (_e, data: any) => {
this.zone.run(() => this.handleGlobalError(data.err))
})
this.player.on('timeupdate', () => {
@ -458,7 +459,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
suspended: () => {
return (
!isXPercentInViewport(this.player.el(), 80) ||
!isXPercentInViewport(this.player.el() as HTMLElement, 80) ||
!document.getElementById('content').contains(document.activeElement)
)
}

View File

@ -1,6 +1,6 @@
import { buildVideoOrPlaylistEmbed } from 'src/assets/player/utils'
import { environment } from 'src/environments/environment'
import { Component, ElementRef, Input, OnInit } from '@angular/core'
import { buildVideoOrPlaylistEmbed } from '@root-helpers/video'
import { buildPlaylistEmbedLink, buildVideoEmbedLink } from '@shared/core-utils'
import { CustomMarkupComponent } from './shared'

View File

@ -1,7 +1,7 @@
import { buildVideoOrPlaylistEmbed } from 'src/assets/player/utils'
import { environment } from 'src/environments/environment'
import { Component, Input, OnInit } from '@angular/core'
import { DomSanitizer, SafeHtml } from '@angular/platform-browser'
import { buildVideoOrPlaylistEmbed } from '@root-helpers/video'
import { buildVideoEmbedLink, decorateVideoLink } from '@shared/core-utils'
import { Video } from '@shared/models'

View File

@ -4,9 +4,9 @@ import { ServerService } from '@app/core'
import { VideoDetails } from '@app/shared/shared-main'
import { VideoPlaylist } from '@app/shared/shared-video-playlist'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { buildVideoOrPlaylistEmbed } from '@root-helpers/video'
import { buildPlaylistLink, buildVideoLink, decoratePlaylistLink, decorateVideoLink } from '@shared/core-utils'
import { VideoCaption, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
import { buildVideoOrPlaylistEmbed } from '../../../assets/player/utils'
type Customizations = {
startAtCheckbox: boolean

View File

@ -1,2 +1,2 @@
export * from './peertube-player-manager'
export * from './manager-options/manager-options.model'
export * from './types'

View File

@ -1,35 +1,34 @@
import '@peertube/videojs-contextmenu'
import './upnext/end-card'
import './upnext/upnext-plugin'
import './stats/stats-card'
import './stats/stats-plugin'
import './bezels/bezels-plugin'
import './peertube-plugin'
import './peertube-resolutions-plugin'
import './control-bar/next-previous-video-button'
import './control-bar/p2p-info-button'
import './control-bar/peertube-link-button'
import './control-bar/peertube-load-progress-bar'
import './control-bar/theater-button'
import './settings/resolution-menu-button'
import './settings/resolution-menu-item'
import './settings/settings-dialog'
import './settings/settings-menu-button'
import './settings/settings-menu-item'
import './settings/settings-panel'
import './settings/settings-panel-child'
import './playlist/playlist-plugin'
import './mobile/peertube-mobile-plugin'
import './mobile/peertube-mobile-buttons'
import './hotkeys/peertube-hotkeys-plugin'
import './shared/upnext/end-card'
import './shared/upnext/upnext-plugin'
import './shared/stats/stats-card'
import './shared/stats/stats-plugin'
import './shared/bezels/bezels-plugin'
import './shared/peertube/peertube-plugin'
import './shared/resolutions/peertube-resolutions-plugin'
import './shared/control-bar/next-previous-video-button'
import './shared/control-bar/p2p-info-button'
import './shared/control-bar/peertube-link-button'
import './shared/control-bar/peertube-load-progress-bar'
import './shared/control-bar/theater-button'
import './shared/settings/resolution-menu-button'
import './shared/settings/resolution-menu-item'
import './shared/settings/settings-dialog'
import './shared/settings/settings-menu-button'
import './shared/settings/settings-menu-item'
import './shared/settings/settings-panel'
import './shared/settings/settings-panel-child'
import './shared/playlist/playlist-plugin'
import './shared/mobile/peertube-mobile-plugin'
import './shared/mobile/peertube-mobile-buttons'
import './shared/hotkeys/peertube-hotkeys-plugin'
import videojs from 'video.js'
import { PluginsManager } from '@root-helpers/plugins-manager'
import { ManagerOptionsBuilder } from './manager-options/manager-options-builder'
import { CommonOptions, PeertubePlayerManagerOptions, PlayerMode } from './manager-options/manager-options.model'
import { isMobile } from '@root-helpers/web-browser'
import { saveAverageBandwidth } from './peertube-player-local-storage'
import { PlayerNetworkInfo } from './peertube-videojs-typings'
import { ManagerOptionsBuilder } from './shared/manager-options'
import { TranslationsManager } from './translations-manager'
import { isMobile } from './utils'
import { CommonOptions, PeertubePlayerManagerOptions, PlayerMode, PlayerNetworkInfo } from './types'
// Change 'Playback Rate' to 'Speed' (smaller for our settings menu)
(videojs.getComponent('PlaybackRateMenuButton') as any).prototype.controlText_ = 'Speed'
@ -60,11 +59,11 @@ export class PeertubePlayerManager {
this.onPlayerChange = onPlayerChange
this.playerElementClassName = options.common.playerElement.className
if (mode === 'webtorrent') await import('./webtorrent/webtorrent-plugin')
if (mode === 'webtorrent') await import('./shared/webtorrent/webtorrent-plugin')
if (mode === 'p2p-media-loader') {
const [ p2pMediaLoaderModule ] = await Promise.all([
import('@peertube/p2p-media-loader-hlsjs'),
import('./p2p-media-loader/p2p-media-loader-plugin')
import('./shared/p2p-media-loader/p2p-media-loader-plugin')
])
this.p2pMediaLoaderModule = p2pMediaLoaderModule
@ -174,7 +173,7 @@ export class PeertubePlayerManager {
this.rebuildAndUpdateVideoElement(currentPlayer, options.common)
await import('./webtorrent/webtorrent-plugin')
await import('./shared/webtorrent/webtorrent-plugin')
const newPlayer = await this.buildPlayer('webtorrent', options)
this.onPlayerChange(newPlayer)

View File

@ -0,0 +1,2 @@
export * from './bezels-plugin'
export * from './pause-bezel'

View File

@ -1,5 +1,5 @@
import videojs from 'video.js'
import { isMobile } from '../utils'
import { isMobile } from '@root-helpers/web-browser'
function getPauseBezel () {
return `

View File

@ -0,0 +1 @@
export * from './utils'

View File

@ -0,0 +1,66 @@
import { VideoFile } from '@shared/models'
function toTitleCase (str: string) {
return str.charAt(0).toUpperCase() + str.slice(1)
}
// https://github.com/danrevah/ngx-pipes/blob/master/src/pipes/math/bytes.ts
// Don't import all Angular stuff, just copy the code with shame
const dictionaryBytes: Array<{max: number, type: string}> = [
{ max: 1024, type: 'B' },
{ max: 1048576, type: 'KB' },
{ max: 1073741824, type: 'MB' },
{ max: 1.0995116e12, type: 'GB' }
]
function bytes (value: number) {
const format = dictionaryBytes.find(d => value < d.max) || dictionaryBytes[dictionaryBytes.length - 1]
const calc = Math.floor(value / (format.max / 1024)).toString()
return [ calc, format.type ]
}
function videoFileMaxByResolution (files: VideoFile[]) {
let max = files[0]
for (let i = 1; i < files.length; i++) {
const file = files[i]
if (max.resolution.id < file.resolution.id) max = file
}
return max
}
function videoFileMinByResolution (files: VideoFile[]) {
let min = files[0]
for (let i = 1; i < files.length; i++) {
const file = files[i]
if (min.resolution.id > file.resolution.id) min = file
}
return min
}
function getRtcConfig () {
return {
iceServers: [
{
urls: 'stun:stun.stunprotocol.org'
},
{
urls: 'stun:stun.framasoft.org'
}
]
}
}
// ---------------------------------------------------------------------------
export {
getRtcConfig,
toTitleCase,
videoFileMaxByResolution,
videoFileMinByResolution,
bytes
}

View File

@ -0,0 +1,5 @@
export * from './next-previous-video-button'
export * from './p2p-info-button'
export * from './peertube-link-button'
export * from './peertube-load-progress-bar'
export * from './theater-button'

View File

@ -1,5 +1,5 @@
import videojs from 'video.js'
import { NextPreviousVideoButtonOptions } from '../peertube-videojs-typings'
import { NextPreviousVideoButtonOptions } from '../../types'
const Button = videojs.getComponent('Button')

View File

@ -1,6 +1,6 @@
import videojs from 'video.js'
import { PeerTubeP2PInfoButtonOptions, PlayerNetworkInfo } from '../peertube-videojs-typings'
import { bytes } from '../utils'
import { PeerTubeP2PInfoButtonOptions, PlayerNetworkInfo } from '../../types'
import { bytes } from '../common'
const Button = videojs.getComponent('Button')
class P2pInfoButton extends Button {

View File

@ -1,6 +1,6 @@
import videojs from 'video.js'
import { buildVideoLink, decorateVideoLink } from '@shared/core-utils'
import { PeerTubeLinkButtonOptions } from '../peertube-videojs-typings'
import { PeerTubeLinkButtonOptions } from '../../types'
const Button = videojs.getComponent('Button')
class PeerTubeLinkButton extends Button {

View File

@ -1,5 +1,5 @@
import videojs from 'video.js'
import { saveTheaterInStore, getStoredTheater } from '../peertube-player-local-storage'
import { getStoredTheater, saveTheaterInStore } from '../../peertube-player-local-storage'
const Button = videojs.getComponent('Button')
class TheaterButton extends Button {

View File

@ -0,0 +1,2 @@
export * from './peertube-dock-component'
export * from './peertube-dock-plugin'

View File

@ -0,0 +1 @@
export * from './peertube-hotkeys-plugin'

View File

@ -1,5 +1,10 @@
import { NextPreviousVideoButtonOptions, PeerTubeLinkButtonOptions } from '../peertube-videojs-typings'
import { CommonOptions, PeertubePlayerManagerOptions, PlayerMode } from './manager-options.model'
import {
CommonOptions,
NextPreviousVideoButtonOptions,
PeerTubeLinkButtonOptions,
PeertubePlayerManagerOptions,
PlayerMode
} from '../../types'
export class ControlBarOptionsBuilder {
private options: CommonOptions
@ -41,7 +46,7 @@ export class ControlBarOptionsBuilder {
muteToggle: {},
volumeControl: {},
settingsButton: this.getSettingsButton()
...this.getSettingsButton()
})
if (this.options.peertubeLink === true) {

View File

@ -1,13 +1,13 @@
import { HybridLoaderSettings } from '@peertube/p2p-media-loader-core'
import { HlsJsEngineSettings } from '@peertube/p2p-media-loader-hlsjs'
import { LiveVideoLatencyMode } from '@shared/models'
import { getAverageBandwidthInStore } from '../../peertube-player-local-storage'
import { P2PMediaLoader, P2PMediaLoaderPluginOptions } from '../../types'
import { PeertubePlayerManagerOptions } from '../../types/manager-options'
import { getRtcConfig } from '../common'
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 { getAverageBandwidthInStore } from '../peertube-player-local-storage'
import { P2PMediaLoader, P2PMediaLoaderPluginOptions } from '../peertube-videojs-typings'
import { getRtcConfig } from '../utils'
import { PeertubePlayerManagerOptions } from './manager-options.model'
export class HLSOptionsBuilder {

View File

@ -0,0 +1 @@
export * from './manager-options-builder'

View File

@ -1,12 +1,13 @@
import videojs from 'video.js'
import { copyToClipboard } from '@root-helpers/utils'
import { buildVideoOrPlaylistEmbed } from '@root-helpers/video'
import { isIOS, isSafari } from '@root-helpers/web-browser'
import { buildVideoLink, decorateVideoLink } from '@shared/core-utils'
import { isDefaultLocale } from '@shared/core-utils/i18n'
import { copyToClipboard } from '../../../root-helpers/utils'
import { VideoJSPluginOptions } from '../peertube-videojs-typings'
import { buildVideoOrPlaylistEmbed, isIOS, isSafari } from '../utils'
import { VideoJSPluginOptions } from '../../types'
import { CommonOptions, PeertubePlayerManagerOptions, PlayerMode } from '../../types/manager-options'
import { ControlBarOptionsBuilder } from './control-bar-options-builder'
import { HLSOptionsBuilder } from './hls-options-builder'
import { CommonOptions, PeertubePlayerManagerOptions, PlayerMode } from './manager-options.model'
import { WebTorrentOptionsBuilder } from './webtorrent-options-builder'
export class ManagerOptionsBuilder {

View File

@ -1,4 +1,4 @@
import { PeertubePlayerManagerOptions } from './manager-options.model'
import { PeertubePlayerManagerOptions } from '../../types'
export class WebTorrentOptionsBuilder {

View File

@ -0,0 +1,2 @@
export * from './peertube-mobile-buttons'
export * from './peertube-mobile-plugin'

View File

@ -3,7 +3,7 @@
import Hlsjs, { ErrorData, HlsConfig, Level, LevelSwitchingData, ManifestParsedData } from 'hls.js'
import videojs from 'video.js'
import { HlsjsConfigHandlerOptions, PeerTubeResolution, VideoJSTechHLS } from '../peertube-videojs-typings'
import { HlsjsConfigHandlerOptions, PeerTubeResolution, VideoJSTechHLS } from '../../types'
type ErrorCounts = {
[ type: string ]: number

View File

@ -0,0 +1,5 @@
export * from './hls-plugin'
export * from './p2p-media-loader-plugin'
export * from './redundancy-url-manager'
export * from './segment-url-builder'
export * from './segment-validator'

View File

@ -3,7 +3,7 @@ import videojs from 'video.js'
import { Events, Segment } from '@peertube/p2p-media-loader-core'
import { Engine, initHlsJsPlayer, initVideoJsContribHlsJsPlayer } from '@peertube/p2p-media-loader-hlsjs'
import { timeToInt } from '@shared/core-utils'
import { P2PMediaLoaderPluginOptions, PlayerNetworkInfo } from '../peertube-videojs-typings'
import { P2PMediaLoaderPluginOptions, PlayerNetworkInfo } from '../../types'
import { registerConfigPlugin, registerSourceHandler } from './hls-plugin'
registerConfigPlugin(videojs)

View File

@ -0,0 +1 @@
export * from './peertube-plugin'

View File

@ -1,5 +1,6 @@
import debug from 'debug'
import videojs from 'video.js'
import { isMobile } from '@root-helpers/web-browser'
import { timeToInt } from '@shared/core-utils'
import {
getStoredLastSubtitle,
@ -9,10 +10,9 @@ import {
saveMuteInStore,
saveVideoWatchHistory,
saveVolumeInStore
} from './peertube-player-local-storage'
import { PeerTubePluginOptions, UserWatching, VideoJSCaption } from './peertube-videojs-typings'
import { SettingsButton } from './settings/settings-menu-button'
import { isMobile } from './utils'
} from '../../peertube-player-local-storage'
import { PeerTubePluginOptions, UserWatching, VideoJSCaption } from '../../types'
import { SettingsButton } from '../settings/settings-menu-button'
const logger = debug('peertube:player:peertube')

View File

@ -0,0 +1,4 @@
export * from './playlist-button'
export * from './playlist-menu-item'
export * from './playlist-menu'
export * from './playlist-plugin'

View File

@ -1,5 +1,5 @@
import videojs from 'video.js'
import { PlaylistPluginOptions } from '../peertube-videojs-typings'
import { PlaylistPluginOptions } from '../../types'
import { PlaylistMenu } from './playlist-menu'
const ClickableComponent = videojs.getComponent('ClickableComponent')

View File

@ -1,7 +1,7 @@
import videojs from 'video.js'
import { secondsToTime } from '@shared/core-utils'
import { VideoPlaylistElement } from '@shared/models'
import { PlaylistItemOptions } from '../peertube-videojs-typings'
import { PlaylistItemOptions } from '../../types'
const Component = videojs.getComponent('Component')

View File

@ -1,6 +1,6 @@
import videojs from 'video.js'
import { VideoPlaylistElement } from '@shared/models'
import { PlaylistPluginOptions } from '../peertube-videojs-typings'
import { PlaylistPluginOptions } from '../../types'
import { PlaylistMenuItem } from './playlist-menu-item'
const Component = videojs.getComponent('Component')

View File

@ -1,5 +1,5 @@
import videojs from 'video.js'
import { PlaylistPluginOptions } from '../peertube-videojs-typings'
import { PlaylistPluginOptions } from '../../types'
import { PlaylistButton } from './playlist-button'
import { PlaylistMenu } from './playlist-menu'
@ -20,7 +20,7 @@ class PlaylistPlugin extends Plugin {
})
this.playlistMenu = new PlaylistMenu(player, options)
this.playlistButton = new PlaylistButton(player, Object.assign({}, options, { playlistMenu: this.playlistMenu }))
this.playlistButton = new PlaylistButton(player, { ...options, playlistMenu: this.playlistMenu })
player.addChild(this.playlistMenu, options)
player.addChild(this.playlistButton, options)

View File

@ -0,0 +1 @@
export * from './peertube-resolutions-plugin'

View File

@ -1,5 +1,5 @@
import videojs from 'video.js'
import { PeerTubeResolution } from './peertube-videojs-typings'
import { PeerTubeResolution } from '../../types'
const Plugin = videojs.getPlugin('plugin')

View File

@ -0,0 +1,7 @@
export * from './resolution-menu-button'
export * from './resolution-menu-item'
export * from './settings-dialog'
export * from './settings-menu-button'
export * from './settings-menu-item'
export * from './settings-panel-child'
export * from './settings-panel'

View File

@ -1,9 +1,7 @@
// Thanks to Yanko Shterev: https://github.com/yshterev/videojs-settings-menu
import { SettingsMenuItem } from './settings-menu-item'
import { toTitleCase } from '../utils'
import videojs from 'video.js'
import { toTitleCase } from '../common'
import { SettingsDialog } from './settings-dialog'
import { SettingsMenuItem } from './settings-menu-item'
import { SettingsPanel } from './settings-panel'
import { SettingsPanelChild } from './settings-panel-child'

View File

@ -1,6 +1,5 @@
import videojs from 'video.js'
// Thanks to Yanko Shterev: https://github.com/yshterev/videojs-settings-menu
import { toTitleCase } from '../utils'
import { toTitleCase } from '../common'
import { SettingsDialog } from './settings-dialog'
import { SettingsButton } from './settings-menu-button'
import { SettingsPanel } from './settings-panel'

View File

@ -0,0 +1,2 @@
export * from './stats-card'
export * from './stats-plugin'

View File

@ -1,7 +1,7 @@
import videojs from 'video.js'
import { secondsToTime } from '@shared/core-utils'
import { PlayerNetworkInfo as EventPlayerNetworkInfo } from '../peertube-videojs-typings'
import { bytes } from '../utils'
import { PlayerNetworkInfo as EventPlayerNetworkInfo } from '../../types'
import { bytes } from '../common'
interface StatsCardOptions extends videojs.ComponentOptions {
videoUUID: string

View File

@ -0,0 +1,2 @@
export * from './end-card'
export * from './upnext-plugin'

View File

@ -1,10 +1,11 @@
import videojs from 'video.js'
import * as WebTorrent from 'webtorrent'
import { isIOS } from '@root-helpers/web-browser'
import { timeToInt } from '@shared/core-utils'
import { VideoFile } from '@shared/models'
import { getAverageBandwidthInStore, getStoredMute, getStoredVolume, saveAverageBandwidth } from '../peertube-player-local-storage'
import { PeerTubeResolution, PlayerNetworkInfo, WebtorrentPluginOptions } from '../peertube-videojs-typings'
import { getRtcConfig, isIOS, videoFileMaxByResolution, videoFileMinByResolution } from '../utils'
import { getAverageBandwidthInStore, getStoredMute, getStoredVolume, saveAverageBandwidth } from '../../peertube-player-local-storage'
import { PeerTubeResolution, PlayerNetworkInfo, WebtorrentPluginOptions } from '../../types'
import { getRtcConfig, videoFileMaxByResolution, videoFileMinByResolution } from '../common'
import { PeertubeChunkStore } from './peertube-chunk-store'
import { renderVideo } from './video-renderer'

View File

@ -0,0 +1,2 @@
export * from './manager-options'
export * from './peertube-videojs-typings'

View File

@ -1,6 +1,6 @@
import { PluginsManager } from '@root-helpers/plugins-manager'
import { LiveVideoLatencyMode, VideoFile } from '@shared/models'
import { PlaylistPluginOptions, UserWatching, VideoJSCaption } from '../peertube-videojs-typings'
import { PlaylistPluginOptions, UserWatching, VideoJSCaption } from './peertube-videojs-typings'
export type PlayerMode = 'webtorrent' | 'p2p-media-loader'

View File

@ -2,18 +2,18 @@ import { HlsConfig, Level } from 'hls.js'
import videojs from 'video.js'
import { Engine } from '@peertube/p2p-media-loader-hlsjs'
import { VideoFile, VideoPlaylist, VideoPlaylistElement } from '@shared/models'
import { PeerTubeDockPluginOptions } from './dock/peertube-dock-plugin'
import { PlayerMode } from './manager-options/manager-options.model'
import { Html5Hlsjs } from './p2p-media-loader/hls-plugin'
import { P2pMediaLoaderPlugin } from './p2p-media-loader/p2p-media-loader-plugin'
import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager'
import { PeerTubePlugin } from './peertube-plugin'
import { PeerTubeResolutionsPlugin } from './peertube-resolutions-plugin'
import { PlaylistPlugin } from './playlist/playlist-plugin'
import { StatsCardOptions } from './stats/stats-card'
import { StatsForNerdsPlugin } from './stats/stats-plugin'
import { EndCardOptions } from './upnext/end-card'
import { WebTorrentPlugin } from './webtorrent/webtorrent-plugin'
import { PeerTubeDockPluginOptions } from '../shared/dock/peertube-dock-plugin'
import { Html5Hlsjs } from '../shared/p2p-media-loader/hls-plugin'
import { P2pMediaLoaderPlugin } from '../shared/p2p-media-loader/p2p-media-loader-plugin'
import { RedundancyUrlManager } from '../shared/p2p-media-loader/redundancy-url-manager'
import { PeerTubePlugin } from '../shared/peertube/peertube-plugin'
import { PlaylistPlugin } from '../shared/playlist/playlist-plugin'
import { PeerTubeResolutionsPlugin } from '../shared/resolutions/peertube-resolutions-plugin'
import { StatsCardOptions } from '../shared/stats/stats-card'
import { StatsForNerdsPlugin } from '../shared/stats/stats-plugin'
import { EndCardOptions } from '../shared/upnext/end-card'
import { WebTorrentPlugin } from '../shared/webtorrent/webtorrent-plugin'
import { PlayerMode } from './manager-options'
declare module 'video.js' {

View File

@ -3,5 +3,6 @@ export * from './bytes'
export * from './images'
export * from './local-storage-utils'
export * from './peertube-web-storage'
export * from './utils'
export * from './plugins-manager'
export * from './utils'
export * from './video'

View File

@ -0,0 +1,33 @@
import { HTMLServerConfig, Video } from '@shared/models'
function buildVideoOrPlaylistEmbed (embedUrl: string, embedTitle: string) {
const iframe = document.createElement('iframe')
iframe.title = embedTitle
iframe.width = '560'
iframe.height = '315'
iframe.src = embedUrl
iframe.frameBorder = '0'
iframe.allowFullscreen = true
iframe.sandbox.add('allow-same-origin', 'allow-scripts', 'allow-popups')
return iframe.outerHTML
}
function isP2PEnabled (video: Video, config: HTMLServerConfig, userP2PEnabled: boolean) {
if (video.isLocal && config.tracker.enabled === false) return false
if (isWebRTCDisabled()) return false
return userP2PEnabled
}
export {
buildVideoOrPlaylistEmbed,
isP2PEnabled
}
// ---------------------------------------------------------------------------
function isWebRTCDisabled () {
return !!((window as any).RTCPeerConnection || (window as any).mozRTCPeerConnection || (window as any).webkitRTCPeerConnection) === false
}

View File

@ -0,0 +1,24 @@
function isIOS () {
if (/iPad|iPhone|iPod/.test(navigator.platform)) {
return true
}
// Detect iPad Desktop mode
return !!(navigator.maxTouchPoints &&
navigator.maxTouchPoints > 2 &&
navigator.platform.includes('MacIntel'))
}
function isSafari () {
return /^((?!chrome|android).)*safari/i.test(navigator.userAgent)
}
function isMobile () {
return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent)
}
export {
isIOS,
isSafari,
isMobile
}

View File

@ -1,6 +1,6 @@
import './embed.scss'
import '../../assets/player/dock/peertube-dock-component'
import '../../assets/player/dock/peertube-dock-plugin'
import '../../assets/player/shared/dock/peertube-dock-component'
import '../../assets/player/shared/dock/peertube-dock-plugin'
import videojs from 'video.js'
import { peertubeTranslate } from '../../../../shared/core-utils/i18n'
import {
@ -17,15 +17,14 @@ import {
VideoPlaylistElement,
VideoStreamingPlaylistType
} from '../../../../shared/models'
import { P2PMediaLoaderOptions, PeertubePlayerManagerOptions, PlayerMode } from '../../assets/player'
import { VideoJSCaption } from '../../assets/player/peertube-videojs-typings'
import { P2PMediaLoaderOptions, PeertubePlayerManagerOptions, PlayerMode, VideoJSCaption } from '../../assets/player'
import { TranslationsManager } from '../../assets/player/translations-manager'
import { isP2PEnabled } from '../../assets/player/utils'
import { getBoolOrDefault } from '../../root-helpers/local-storage-utils'
import { peertubeLocalStorage } from '../../root-helpers/peertube-web-storage'
import { PluginsManager } from '../../root-helpers/plugins-manager'
import { UserLocalStorageKeys, UserTokens } from '../../root-helpers/users'
import { objectToUrlEncoded } from '../../root-helpers/utils'
import { isP2PEnabled } from '../../root-helpers/video'
import { RegisterClientHelpers } from '../../types/register-client-option.model'
import { PeerTubeEmbedApi } from './embed-api'