]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Reorganize player files
authorChocobozzz <me@florianbigard.com>
Mon, 14 Mar 2022 13:28:20 +0000 (14:28 +0100)
committerChocobozzz <me@florianbigard.com>
Mon, 14 Mar 2022 13:36:35 +0000 (14:36 +0100)
72 files changed:
client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts
client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts
client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts
client/src/app/+videos/+video-watch/video-watch.component.ts
client/src/app/shared/shared-custom-markup/peertube-custom-tags/embed-markup.component.ts
client/src/app/shared/shared-main/video/embed.component.ts
client/src/app/shared/shared-share-modal/video-share.component.ts
client/src/assets/player/index.ts
client/src/assets/player/peertube-player-manager.ts
client/src/assets/player/shared/bezels/bezels-plugin.ts [moved from client/src/assets/player/bezels/bezels-plugin.ts with 100% similarity]
client/src/assets/player/shared/bezels/index.ts [new file with mode: 0644]
client/src/assets/player/shared/bezels/pause-bezel.ts [moved from client/src/assets/player/bezels/pause-bezel.ts with 97% similarity]
client/src/assets/player/shared/common/index.ts [new file with mode: 0644]
client/src/assets/player/shared/common/utils.ts [new file with mode: 0644]
client/src/assets/player/shared/control-bar/index.ts [new file with mode: 0644]
client/src/assets/player/shared/control-bar/next-previous-video-button.ts [moved from client/src/assets/player/control-bar/next-previous-video-button.ts with 94% similarity]
client/src/assets/player/shared/control-bar/p2p-info-button.ts [moved from client/src/assets/player/control-bar/p2p-info-button.ts with 98% similarity]
client/src/assets/player/shared/control-bar/peertube-link-button.ts [moved from client/src/assets/player/control-bar/peertube-link-button.ts with 94% similarity]
client/src/assets/player/shared/control-bar/peertube-load-progress-bar.ts [moved from client/src/assets/player/control-bar/peertube-load-progress-bar.ts with 100% similarity]
client/src/assets/player/shared/control-bar/theater-button.ts [moved from client/src/assets/player/control-bar/theater-button.ts with 93% similarity]
client/src/assets/player/shared/dock/index.ts [new file with mode: 0644]
client/src/assets/player/shared/dock/peertube-dock-component.ts [moved from client/src/assets/player/dock/peertube-dock-component.ts with 100% similarity]
client/src/assets/player/shared/dock/peertube-dock-plugin.ts [moved from client/src/assets/player/dock/peertube-dock-plugin.ts with 100% similarity]
client/src/assets/player/shared/hotkeys/index.ts [new file with mode: 0644]
client/src/assets/player/shared/hotkeys/peertube-hotkeys-plugin.ts [moved from client/src/assets/player/hotkeys/peertube-hotkeys-plugin.ts with 100% similarity]
client/src/assets/player/shared/manager-options/control-bar-options-builder.ts [moved from client/src/assets/player/manager-options/control-bar-options-builder.ts with 91% similarity]
client/src/assets/player/shared/manager-options/hls-options-builder.ts [moved from client/src/assets/player/manager-options/hls-options-builder.ts with 96% similarity]
client/src/assets/player/shared/manager-options/index.ts [new file with mode: 0644]
client/src/assets/player/shared/manager-options/manager-options-builder.ts [moved from client/src/assets/player/manager-options/manager-options-builder.ts with 95% similarity]
client/src/assets/player/shared/manager-options/webtorrent-options-builder.ts [moved from client/src/assets/player/manager-options/webtorrent-options-builder.ts with 92% similarity]
client/src/assets/player/shared/mobile/index.ts [new file with mode: 0644]
client/src/assets/player/shared/mobile/peertube-mobile-buttons.ts [moved from client/src/assets/player/mobile/peertube-mobile-buttons.ts with 100% similarity]
client/src/assets/player/shared/mobile/peertube-mobile-plugin.ts [moved from client/src/assets/player/mobile/peertube-mobile-plugin.ts with 100% similarity]
client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts [moved from client/src/assets/player/p2p-media-loader/hls-plugin.ts with 99% similarity]
client/src/assets/player/shared/p2p-media-loader/index.ts [new file with mode: 0644]
client/src/assets/player/shared/p2p-media-loader/p2p-media-loader-plugin.ts [moved from client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts with 99% similarity]
client/src/assets/player/shared/p2p-media-loader/redundancy-url-manager.ts [moved from client/src/assets/player/p2p-media-loader/redundancy-url-manager.ts with 100% similarity]
client/src/assets/player/shared/p2p-media-loader/segment-url-builder.ts [moved from client/src/assets/player/p2p-media-loader/segment-url-builder.ts with 100% similarity]
client/src/assets/player/shared/p2p-media-loader/segment-validator.ts [moved from client/src/assets/player/p2p-media-loader/segment-validator.ts with 100% similarity]
client/src/assets/player/shared/peertube/index.ts [new file with mode: 0644]
client/src/assets/player/shared/peertube/peertube-plugin.ts [moved from client/src/assets/player/peertube-plugin.ts with 97% similarity]
client/src/assets/player/shared/playlist/index.ts [new file with mode: 0644]
client/src/assets/player/shared/playlist/playlist-button.ts [moved from client/src/assets/player/playlist/playlist-button.ts with 95% similarity]
client/src/assets/player/shared/playlist/playlist-menu-item.ts [moved from client/src/assets/player/playlist/playlist-menu-item.ts with 98% similarity]
client/src/assets/player/shared/playlist/playlist-menu.ts [moved from client/src/assets/player/playlist/playlist-menu.ts with 97% similarity]
client/src/assets/player/shared/playlist/playlist-plugin.ts [moved from client/src/assets/player/playlist/playlist-plugin.ts with 82% similarity]
client/src/assets/player/shared/resolutions/index.ts [new file with mode: 0644]
client/src/assets/player/shared/resolutions/peertube-resolutions-plugin.ts [moved from client/src/assets/player/peertube-resolutions-plugin.ts with 96% similarity]
client/src/assets/player/shared/settings/index.ts [new file with mode: 0644]
client/src/assets/player/shared/settings/resolution-menu-button.ts [moved from client/src/assets/player/settings/resolution-menu-button.ts with 100% similarity]
client/src/assets/player/shared/settings/resolution-menu-item.ts [moved from client/src/assets/player/settings/resolution-menu-item.ts with 100% similarity]
client/src/assets/player/shared/settings/settings-dialog.ts [moved from client/src/assets/player/settings/settings-dialog.ts with 100% similarity]
client/src/assets/player/shared/settings/settings-menu-button.ts [moved from client/src/assets/player/settings/settings-menu-button.ts with 98% similarity]
client/src/assets/player/shared/settings/settings-menu-item.ts [moved from client/src/assets/player/settings/settings-menu-item.ts with 98% similarity]
client/src/assets/player/shared/settings/settings-panel-child.ts [moved from client/src/assets/player/settings/settings-panel-child.ts with 100% similarity]
client/src/assets/player/shared/settings/settings-panel.ts [moved from client/src/assets/player/settings/settings-panel.ts with 100% similarity]
client/src/assets/player/shared/stats/index.ts [new file with mode: 0644]
client/src/assets/player/shared/stats/stats-card.ts [moved from client/src/assets/player/stats/stats-card.ts with 99% similarity]
client/src/assets/player/shared/stats/stats-plugin.ts [moved from client/src/assets/player/stats/stats-plugin.ts with 100% similarity]
client/src/assets/player/shared/upnext/end-card.ts [moved from client/src/assets/player/upnext/end-card.ts with 100% similarity]
client/src/assets/player/shared/upnext/index.ts [new file with mode: 0644]
client/src/assets/player/shared/upnext/upnext-plugin.ts [moved from client/src/assets/player/upnext/upnext-plugin.ts with 100% similarity]
client/src/assets/player/shared/webtorrent/peertube-chunk-store.ts [moved from client/src/assets/player/webtorrent/peertube-chunk-store.ts with 100% similarity]
client/src/assets/player/shared/webtorrent/video-renderer.ts [moved from client/src/assets/player/webtorrent/video-renderer.ts with 100% similarity]
client/src/assets/player/shared/webtorrent/webtorrent-plugin.ts [moved from client/src/assets/player/webtorrent/webtorrent-plugin.ts with 98% similarity]
client/src/assets/player/types/index.ts [new file with mode: 0644]
client/src/assets/player/types/manager-options.ts [moved from client/src/assets/player/manager-options/manager-options.model.ts with 98% similarity]
client/src/assets/player/types/peertube-videojs-typings.ts [moved from client/src/assets/player/peertube-videojs-typings.ts with 82% similarity]
client/src/root-helpers/index.ts
client/src/root-helpers/video.ts [new file with mode: 0644]
client/src/root-helpers/web-browser.ts [new file with mode: 0644]
client/src/standalone/videos/embed.ts

index 67752c15a60297832f0f659fa2c836d959420ee7..033305a2b7cf0b0f3c5d4864daf13d5af5cc45dd 100644 (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'
 
index fb6f2601b3ea6f93b314cbe2859f7bb533901b80..5655e48da4e4e6cfb772c35ab817fdc51d40e680 100644 (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'
index 24030df3e492bcae305e7de9b7aa22a98333266d..b51457e0266b438f261ff4da8c481d0a8581ebbd 100644 (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',
index 067d3bc841d303821b6323e4e5cc502c3ea31387..f13c885f2a1110d7db329beb25cf88001296e379 100644 (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)
           )
         }
index 53b70cc4759aeaf714ada1dcf01cdfa7a51120b0..955b0af18485921a7b96b53cb6d5a55c622026b7 100644 (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'
 
index 4732efa443231c96cfd35418109deb19df49ca5c..1230008346233aa5b610fc6b0cefbade7a33365f 100644 (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'
 
index 36a4d75209d99e1a7ba9dd8c38da100dab0e9ea8..2346f03e4c71ce79e54f9853293327a1f16ac628 100644 (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
index 92270476d75c75c3a6321f2a34087d98071e5de1..9b87afc4ab9bce58c8b98320f20f9fe26eb8549f 100644 (file)
@@ -1,2 +1,2 @@
 export * from './peertube-player-manager'
-export * from './manager-options/manager-options.model'
+export * from './types'
index ddb521a52f311a90cf18acd9fedc30c2a8709a07..1b2a67c770446aabdee69a025934949973e27383 100644 (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)
diff --git a/client/src/assets/player/shared/bezels/index.ts b/client/src/assets/player/shared/bezels/index.ts
new file mode 100644 (file)
index 0000000..da861b0
--- /dev/null
@@ -0,0 +1,2 @@
+export * from './bezels-plugin'
+export * from './pause-bezel'
similarity index 97%
rename from client/src/assets/player/bezels/pause-bezel.ts
rename to client/src/assets/player/shared/bezels/pause-bezel.ts
index 3159643118679f376d4d150cc3ea0e4c230c7d86..e35c39a5fb5893765a36a4583329ec72f7827f2a 100644 (file)
@@ -1,5 +1,5 @@
 import videojs from 'video.js'
-import { isMobile } from '../utils'
+import { isMobile } from '@root-helpers/web-browser'
 
 function getPauseBezel () {
   return `
diff --git a/client/src/assets/player/shared/common/index.ts b/client/src/assets/player/shared/common/index.ts
new file mode 100644 (file)
index 0000000..9c56149
--- /dev/null
@@ -0,0 +1 @@
+export * from './utils'
diff --git a/client/src/assets/player/shared/common/utils.ts b/client/src/assets/player/shared/common/utils.ts
new file mode 100644 (file)
index 0000000..da7dda0
--- /dev/null
@@ -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
+}
diff --git a/client/src/assets/player/shared/control-bar/index.ts b/client/src/assets/player/shared/control-bar/index.ts
new file mode 100644 (file)
index 0000000..db5b893
--- /dev/null
@@ -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'
similarity index 94%
rename from client/src/assets/player/control-bar/next-previous-video-button.ts
rename to client/src/assets/player/shared/control-bar/next-previous-video-button.ts
index fe17ce2cef29e234c9764a824a488ba146757cc8..b7b986806523921cab12b1f085cd7efd5a56e83b 100644 (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')
 
similarity index 98%
rename from client/src/assets/player/control-bar/p2p-info-button.ts
rename to client/src/assets/player/shared/control-bar/p2p-info-button.ts
index 081dee1d3ddfa73c850651a9194771e7fa0bd52b..36517e125dac5b7a2ab2ed05a189028a6fa50a32 100644 (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 {
similarity index 94%
rename from client/src/assets/player/control-bar/peertube-link-button.ts
rename to client/src/assets/player/shared/control-bar/peertube-link-button.ts
index c49cee5662ae2bb6562b8caa99268487ca8585cb..6d83263cc9e2c0b04ed225c79c913b5dc8369854 100644 (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 {
similarity index 93%
rename from client/src/assets/player/control-bar/theater-button.ts
rename to client/src/assets/player/shared/control-bar/theater-button.ts
index f862ee2242ed02ec4f738c2d42667203f2f4dc3e..56c349d6bbed3a2fbaa4b9e6a71c3003fbc9efd8 100644 (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 {
diff --git a/client/src/assets/player/shared/dock/index.ts b/client/src/assets/player/shared/dock/index.ts
new file mode 100644 (file)
index 0000000..16e70a9
--- /dev/null
@@ -0,0 +1,2 @@
+export * from './peertube-dock-component'
+export * from './peertube-dock-plugin'
diff --git a/client/src/assets/player/shared/hotkeys/index.ts b/client/src/assets/player/shared/hotkeys/index.ts
new file mode 100644 (file)
index 0000000..cc99a1e
--- /dev/null
@@ -0,0 +1 @@
+export * from './peertube-hotkeys-plugin'
similarity index 91%
rename from client/src/assets/player/manager-options/control-bar-options-builder.ts
rename to client/src/assets/player/shared/manager-options/control-bar-options-builder.ts
index 54e61c5d0e9c6d8a7b42a554880953e0fe07b18b..72a10eb2632afaeb374631cb8cf898151836859f 100644 (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) {
similarity index 96%
rename from client/src/assets/player/manager-options/hls-options-builder.ts
rename to client/src/assets/player/shared/manager-options/hls-options-builder.ts
index 9de23561b656cc1ff9e68fb37c95ce3a77f54384..e7f664fd446f03c8bf07c96299bb8a338e3cc455 100644 (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 {
 
diff --git a/client/src/assets/player/shared/manager-options/index.ts b/client/src/assets/player/shared/manager-options/index.ts
new file mode 100644 (file)
index 0000000..4934d83
--- /dev/null
@@ -0,0 +1 @@
+export * from './manager-options-builder'
similarity index 95%
rename from client/src/assets/player/manager-options/manager-options-builder.ts
rename to client/src/assets/player/shared/manager-options/manager-options-builder.ts
index 14bdb5d966ba8c79fa04466200100a9332eee976..5dab1f7a9cce49c3112f8637c6d924fb0e8329a2 100644 (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 {
similarity index 92%
rename from client/src/assets/player/manager-options/webtorrent-options-builder.ts
rename to client/src/assets/player/shared/manager-options/webtorrent-options-builder.ts
index 303940b297cf317ac52e0ac602ad8ee07aaeff6c..257cf1e0567b2799de3ba1dd36683432809090b7 100644 (file)
@@ -1,4 +1,4 @@
-import { PeertubePlayerManagerOptions } from './manager-options.model'
+import { PeertubePlayerManagerOptions } from '../../types'
 
 export class WebTorrentOptionsBuilder {
 
diff --git a/client/src/assets/player/shared/mobile/index.ts b/client/src/assets/player/shared/mobile/index.ts
new file mode 100644 (file)
index 0000000..6f42b8d
--- /dev/null
@@ -0,0 +1,2 @@
+export * from './peertube-mobile-buttons'
+export * from './peertube-mobile-plugin'
similarity index 99%
rename from client/src/assets/player/p2p-media-loader/hls-plugin.ts
rename to client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts
index ccee2d90ffc0e1730b13a22961a772b0d1bf3249..d0105fa36f22176b6194036a848d48c917f3f797 100644 (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
diff --git a/client/src/assets/player/shared/p2p-media-loader/index.ts b/client/src/assets/player/shared/p2p-media-loader/index.ts
new file mode 100644 (file)
index 0000000..02fe71e
--- /dev/null
@@ -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'
similarity index 99%
rename from client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts
rename to client/src/assets/player/shared/p2p-media-loader/p2p-media-loader-plugin.ts
index 1d7a39b4e72b68f090805a5434aeb8ace0a28368..5c0f0021f37de04551298732e1fd5ccff5bcce23 100644 (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)
diff --git a/client/src/assets/player/shared/peertube/index.ts b/client/src/assets/player/shared/peertube/index.ts
new file mode 100644 (file)
index 0000000..ff4d524
--- /dev/null
@@ -0,0 +1 @@
+export * from './peertube-plugin'
similarity index 97%
rename from client/src/assets/player/peertube-plugin.ts
rename to client/src/assets/player/shared/peertube/peertube-plugin.ts
index 4ffc9ce3e7b5b964c7bfffc2104f7e22c758cbf1..1dc3e3de096869c61367bf3c19111368a25892ee 100644 (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')
 
diff --git a/client/src/assets/player/shared/playlist/index.ts b/client/src/assets/player/shared/playlist/index.ts
new file mode 100644 (file)
index 0000000..0be6e4d
--- /dev/null
@@ -0,0 +1,4 @@
+export * from './playlist-button'
+export * from './playlist-menu-item'
+export * from './playlist-menu'
+export * from './playlist-plugin'
similarity index 95%
rename from client/src/assets/player/playlist/playlist-button.ts
rename to client/src/assets/player/shared/playlist/playlist-button.ts
index a7996ec60c7d853fd4e4b71acee2f1b40c9992e9..6cfaf4158961f691a883621cde63a427ad6e9dfd 100644 (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')
similarity index 98%
rename from client/src/assets/player/playlist/playlist-menu-item.ts
rename to client/src/assets/player/shared/playlist/playlist-menu-item.ts
index 2519a34c780fd841c10ce6b018cc40ed1eebbc2f..81b5acf30800d344c6ac7093241a22ee88f49801 100644 (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')
 
similarity index 97%
rename from client/src/assets/player/playlist/playlist-menu.ts
rename to client/src/assets/player/shared/playlist/playlist-menu.ts
index a2583047ba6ffb0566b9ef90c60efc7d28fa41cb..1ec9ac804d9254d6787d36cf183b8cb84c417889 100644 (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')
similarity index 82%
rename from client/src/assets/player/playlist/playlist-plugin.ts
rename to client/src/assets/player/shared/playlist/playlist-plugin.ts
index b69d82e3c4bd69c11bc06e2fe123b5a733e767cf..44de0da5a7c8d315a51b730855e26835d07fddd9 100644 (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)
diff --git a/client/src/assets/player/shared/resolutions/index.ts b/client/src/assets/player/shared/resolutions/index.ts
new file mode 100644 (file)
index 0000000..e56473f
--- /dev/null
@@ -0,0 +1 @@
+export * from './peertube-resolutions-plugin'
similarity index 96%
rename from client/src/assets/player/peertube-resolutions-plugin.ts
rename to client/src/assets/player/shared/resolutions/peertube-resolutions-plugin.ts
index cc36f18f37d1f53bb62590c8f4a3ba272ab2f088..e7899ac71a0459c337e80c2d572604524ca4e1b1 100644 (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')
 
diff --git a/client/src/assets/player/shared/settings/index.ts b/client/src/assets/player/shared/settings/index.ts
new file mode 100644 (file)
index 0000000..736d50c
--- /dev/null
@@ -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'
similarity index 98%
rename from client/src/assets/player/settings/settings-menu-button.ts
rename to client/src/assets/player/shared/settings/settings-menu-button.ts
index 6de390f4d9890b789b664b20c1bf13c34b197316..64866aab202ec07666bccdaceaaacc4a29af7cda 100644 (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'
 
similarity index 98%
rename from client/src/assets/player/settings/settings-menu-item.ts
rename to client/src/assets/player/shared/settings/settings-menu-item.ts
index 31d42c456dabd73236e8b68fbb0b6189afff90f6..8d1819a2d40cb5a8a27ecd5be930ce77fbc9bc92 100644 (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'
diff --git a/client/src/assets/player/shared/stats/index.ts b/client/src/assets/player/shared/stats/index.ts
new file mode 100644 (file)
index 0000000..017ec04
--- /dev/null
@@ -0,0 +1,2 @@
+export * from './stats-card'
+export * from './stats-plugin'
similarity index 99%
rename from client/src/assets/player/stats/stats-card.ts
rename to client/src/assets/player/shared/stats/stats-card.ts
index e76a81a74e6bedac7cd287fbd5e4f3fa71260af4..1bf631d2cf2ef71cfda0e23641ee80ec34bae967 100644 (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
diff --git a/client/src/assets/player/shared/upnext/index.ts b/client/src/assets/player/shared/upnext/index.ts
new file mode 100644 (file)
index 0000000..c63c5fd
--- /dev/null
@@ -0,0 +1,2 @@
+export * from './end-card'
+export * from './upnext-plugin'
similarity index 98%
rename from client/src/assets/player/webtorrent/webtorrent-plugin.ts
rename to client/src/assets/player/shared/webtorrent/webtorrent-plugin.ts
index 4bcb2766a66d673f37e713d6b5836f0ec59004fd..b482031483be2fd34bb92dea1a86101a6c9f3dd7 100644 (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'
 
diff --git a/client/src/assets/player/types/index.ts b/client/src/assets/player/types/index.ts
new file mode 100644 (file)
index 0000000..b73e0b3
--- /dev/null
@@ -0,0 +1,2 @@
+export * from './manager-options'
+export * from './peertube-videojs-typings'
similarity index 98%
rename from client/src/assets/player/manager-options/manager-options.model.ts
rename to client/src/assets/player/types/manager-options.ts
index 0b0f8b4350c5844d08712da2b1233ed27d725f10..b3ad7e337bbae8677846f02f1d55cdbc3998264b 100644 (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'
 
similarity index 82%
rename from client/src/assets/player/peertube-videojs-typings.ts
rename to client/src/assets/player/types/peertube-videojs-typings.ts
index fcaa8a9c359eb817dfaa7509b48dbba3718b55c1..d9a388681ff9381ed9b32251e3eb36934d2e2d05 100644 (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' {
 
index aa3b442dde346189748f1ca01b55c4badd80124a..3b95b4b99b3fe5203ddb302b69b15f1469256549 100644 (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'
diff --git a/client/src/root-helpers/video.ts b/client/src/root-helpers/video.ts
new file mode 100644 (file)
index 0000000..4290992
--- /dev/null
@@ -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
+}
diff --git a/client/src/root-helpers/web-browser.ts b/client/src/root-helpers/web-browser.ts
new file mode 100644 (file)
index 0000000..9dade20
--- /dev/null
@@ -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
+}
index 9e4d879112fbfcf4d40c7a8ea0b6ed23d5a491b9..55c26ec3be199bcdc6592da367968c6bd0c68ad1 100644 (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'