diff options
author | Chocobozzz <me@florianbigard.com> | 2022-03-14 14:28:20 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-03-14 14:36:35 +0100 |
commit | 57d6503286b114fee61b5e4725825e2490dcac29 (patch) | |
tree | 2d3d23f697b2986d7e41bb443754394296b66ec3 /client | |
parent | 9597920ee3d4ac99803e7107983ddf98a9dfb3c4 (diff) | |
download | PeerTube-57d6503286b114fee61b5e4725825e2490dcac29.tar.gz PeerTube-57d6503286b114fee61b5e4725825e2490dcac29.tar.zst PeerTube-57d6503286b114fee61b5e4725825e2490dcac29.zip |
Reorganize player files
Diffstat (limited to 'client')
72 files changed, 267 insertions, 102 deletions
diff --git a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts index 67752c15a..033305a2b 100644 --- a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts +++ b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import { SortMeta } from 'primeng/api' | 1 | import { SortMeta } from 'primeng/api' |
2 | import { switchMap } from 'rxjs/operators' | 2 | import { switchMap } from 'rxjs/operators' |
3 | import { buildVideoOrPlaylistEmbed } from 'src/assets/player/utils' | ||
4 | import { environment } from 'src/environments/environment' | 3 | import { environment } from 'src/environments/environment' |
5 | import { Component, OnInit } from '@angular/core' | 4 | import { Component, OnInit } from '@angular/core' |
6 | import { ActivatedRoute, Router } from '@angular/router' | 5 | import { ActivatedRoute, Router } from '@angular/router' |
@@ -8,6 +7,7 @@ import { ConfirmService, MarkdownService, Notifier, RestPagination, RestTable, S | |||
8 | import { AdvancedInputFilter } from '@app/shared/shared-forms' | 7 | import { AdvancedInputFilter } from '@app/shared/shared-forms' |
9 | import { DropdownAction, VideoService } from '@app/shared/shared-main' | 8 | import { DropdownAction, VideoService } from '@app/shared/shared-main' |
10 | import { VideoBlockService } from '@app/shared/shared-moderation' | 9 | import { VideoBlockService } from '@app/shared/shared-moderation' |
10 | import { buildVideoOrPlaylistEmbed } from '@root-helpers/video' | ||
11 | import { buildVideoEmbedLink, decorateVideoLink } from '@shared/core-utils' | 11 | import { buildVideoEmbedLink, decorateVideoLink } from '@shared/core-utils' |
12 | import { VideoBlacklist, VideoBlacklistType } from '@shared/models' | 12 | import { VideoBlacklist, VideoBlacklistType } from '@shared/models' |
13 | 13 | ||
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts index fb6f2601b..5655e48da 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { truncate } from 'lodash-es' | 1 | import { truncate } from 'lodash-es' |
2 | import { UploadState, UploadxOptions, UploadxService } from 'ngx-uploadx' | 2 | import { UploadState, UploadxOptions, UploadxService } from 'ngx-uploadx' |
3 | import { isIOS } from 'src/assets/player/utils' | 3 | import { isIOS } from '@root-helpers/web-browser' |
4 | import { HttpErrorResponse, HttpEventType, HttpHeaders } from '@angular/common/http' | 4 | import { HttpErrorResponse, HttpEventType, HttpHeaders } from '@angular/common/http' |
5 | import { AfterViewInit, Component, ElementRef, EventEmitter, OnDestroy, OnInit, Output, ViewChild } from '@angular/core' | 5 | import { AfterViewInit, Component, ElementRef, EventEmitter, OnDestroy, OnInit, Output, ViewChild } from '@angular/core' |
6 | import { Router } from '@angular/router' | 6 | import { Router } from '@angular/router' |
diff --git a/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts b/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts index 24030df3e..b51457e02 100644 --- a/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts +++ b/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | import { Component, Input, OnInit } from '@angular/core' | 1 | import { Component, Input, OnInit } from '@angular/core' |
2 | import { ServerService, User, UserService } from '@app/core' | 2 | import { ServerService, User, UserService } from '@app/core' |
3 | import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' | 3 | import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' |
4 | import { isP2PEnabled } from '@root-helpers/video' | ||
4 | import { HTMLServerConfig, Video } from '@shared/models' | 5 | import { HTMLServerConfig, Video } from '@shared/models' |
5 | import { isP2PEnabled } from '../../../../../assets/player/utils' | ||
6 | 6 | ||
7 | @Component({ | 7 | @Component({ |
8 | selector: 'my-privacy-concerns', | 8 | selector: 'my-privacy-concerns', |
diff --git a/client/src/app/+videos/+video-watch/video-watch.component.ts b/client/src/app/+videos/+video-watch/video-watch.component.ts index 067d3bc84..f13c885f2 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.ts +++ b/client/src/app/+videos/+video-watch/video-watch.component.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { Hotkey, HotkeysService } from 'angular2-hotkeys' | 1 | import { Hotkey, HotkeysService } from 'angular2-hotkeys' |
2 | import { forkJoin, map, Observable, of, Subscription, switchMap } from 'rxjs' | 2 | import { forkJoin, map, Observable, of, Subscription, switchMap } from 'rxjs' |
3 | import { isP2PEnabled } from 'src/assets/player/utils' | 3 | import { VideoJsPlayer } from 'video.js' |
4 | import { PlatformLocation } from '@angular/common' | 4 | import { PlatformLocation } from '@angular/common' |
5 | import { Component, ElementRef, Inject, LOCALE_ID, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core' | 5 | import { Component, ElementRef, Inject, LOCALE_ID, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core' |
6 | import { ActivatedRoute, Router } from '@angular/router' | 6 | import { ActivatedRoute, Router } from '@angular/router' |
@@ -24,6 +24,7 @@ import { Video, VideoCaptionService, VideoDetails, VideoService } from '@app/sha | |||
24 | import { SubscribeButtonComponent } from '@app/shared/shared-user-subscription' | 24 | import { SubscribeButtonComponent } from '@app/shared/shared-user-subscription' |
25 | import { LiveVideoService } from '@app/shared/shared-video-live' | 25 | import { LiveVideoService } from '@app/shared/shared-video-live' |
26 | import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' | 26 | import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' |
27 | import { isP2PEnabled } from '@root-helpers/video' | ||
27 | import { timeToInt } from '@shared/core-utils' | 28 | import { timeToInt } from '@shared/core-utils' |
28 | import { | 29 | import { |
29 | HTMLServerConfig, | 30 | HTMLServerConfig, |
@@ -58,7 +59,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
58 | @ViewChild('videoWatchPlaylist', { static: true }) videoWatchPlaylist: VideoWatchPlaylistComponent | 59 | @ViewChild('videoWatchPlaylist', { static: true }) videoWatchPlaylist: VideoWatchPlaylistComponent |
59 | @ViewChild('subscribeButton') subscribeButton: SubscribeButtonComponent | 60 | @ViewChild('subscribeButton') subscribeButton: SubscribeButtonComponent |
60 | 61 | ||
61 | player: any | 62 | player: VideoJsPlayer |
62 | playerElement: HTMLVideoElement | 63 | playerElement: HTMLVideoElement |
63 | playerPlaceholderImgSrc: string | 64 | playerPlaceholderImgSrc: string |
64 | theaterEnabled = false | 65 | theaterEnabled = false |
@@ -418,8 +419,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
418 | this.zone.runOutsideAngular(async () => { | 419 | this.zone.runOutsideAngular(async () => { |
419 | this.player = await PeertubePlayerManager.initialize(playerMode, playerOptions, player => this.player = player) | 420 | this.player = await PeertubePlayerManager.initialize(playerMode, playerOptions, player => this.player = player) |
420 | 421 | ||
421 | this.player.on('customError', ({ err }: { err: any }) => { | 422 | this.player.on('customError', (_e, data: any) => { |
422 | this.zone.run(() => this.handleGlobalError(err)) | 423 | this.zone.run(() => this.handleGlobalError(data.err)) |
423 | }) | 424 | }) |
424 | 425 | ||
425 | this.player.on('timeupdate', () => { | 426 | this.player.on('timeupdate', () => { |
@@ -458,7 +459,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
458 | 459 | ||
459 | suspended: () => { | 460 | suspended: () => { |
460 | return ( | 461 | return ( |
461 | !isXPercentInViewport(this.player.el(), 80) || | 462 | !isXPercentInViewport(this.player.el() as HTMLElement, 80) || |
462 | !document.getElementById('content').contains(document.activeElement) | 463 | !document.getElementById('content').contains(document.activeElement) |
463 | ) | 464 | ) |
464 | } | 465 | } |
diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/embed-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/embed-markup.component.ts index 53b70cc47..955b0af18 100644 --- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/embed-markup.component.ts +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/embed-markup.component.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { buildVideoOrPlaylistEmbed } from 'src/assets/player/utils' | ||
2 | import { environment } from 'src/environments/environment' | 1 | import { environment } from 'src/environments/environment' |
3 | import { Component, ElementRef, Input, OnInit } from '@angular/core' | 2 | import { Component, ElementRef, Input, OnInit } from '@angular/core' |
3 | import { buildVideoOrPlaylistEmbed } from '@root-helpers/video' | ||
4 | import { buildPlaylistEmbedLink, buildVideoEmbedLink } from '@shared/core-utils' | 4 | import { buildPlaylistEmbedLink, buildVideoEmbedLink } from '@shared/core-utils' |
5 | import { CustomMarkupComponent } from './shared' | 5 | import { CustomMarkupComponent } from './shared' |
6 | 6 | ||
diff --git a/client/src/app/shared/shared-main/video/embed.component.ts b/client/src/app/shared/shared-main/video/embed.component.ts index 4732efa44..123000834 100644 --- a/client/src/app/shared/shared-main/video/embed.component.ts +++ b/client/src/app/shared/shared-main/video/embed.component.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { buildVideoOrPlaylistEmbed } from 'src/assets/player/utils' | ||
2 | import { environment } from 'src/environments/environment' | 1 | import { environment } from 'src/environments/environment' |
3 | import { Component, Input, OnInit } from '@angular/core' | 2 | import { Component, Input, OnInit } from '@angular/core' |
4 | import { DomSanitizer, SafeHtml } from '@angular/platform-browser' | 3 | import { DomSanitizer, SafeHtml } from '@angular/platform-browser' |
4 | import { buildVideoOrPlaylistEmbed } from '@root-helpers/video' | ||
5 | import { buildVideoEmbedLink, decorateVideoLink } from '@shared/core-utils' | 5 | import { buildVideoEmbedLink, decorateVideoLink } from '@shared/core-utils' |
6 | import { Video } from '@shared/models' | 6 | import { Video } from '@shared/models' |
7 | 7 | ||
diff --git a/client/src/app/shared/shared-share-modal/video-share.component.ts b/client/src/app/shared/shared-share-modal/video-share.component.ts index 36a4d7520..2346f03e4 100644 --- a/client/src/app/shared/shared-share-modal/video-share.component.ts +++ b/client/src/app/shared/shared-share-modal/video-share.component.ts | |||
@@ -4,9 +4,9 @@ import { ServerService } from '@app/core' | |||
4 | import { VideoDetails } from '@app/shared/shared-main' | 4 | import { VideoDetails } from '@app/shared/shared-main' |
5 | import { VideoPlaylist } from '@app/shared/shared-video-playlist' | 5 | import { VideoPlaylist } from '@app/shared/shared-video-playlist' |
6 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | 6 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
7 | import { buildVideoOrPlaylistEmbed } from '@root-helpers/video' | ||
7 | import { buildPlaylistLink, buildVideoLink, decoratePlaylistLink, decorateVideoLink } from '@shared/core-utils' | 8 | import { buildPlaylistLink, buildVideoLink, decoratePlaylistLink, decorateVideoLink } from '@shared/core-utils' |
8 | import { VideoCaption, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' | 9 | import { VideoCaption, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' |
9 | import { buildVideoOrPlaylistEmbed } from '../../../assets/player/utils' | ||
10 | 10 | ||
11 | type Customizations = { | 11 | type Customizations = { |
12 | startAtCheckbox: boolean | 12 | startAtCheckbox: boolean |
diff --git a/client/src/assets/player/index.ts b/client/src/assets/player/index.ts index 92270476d..9b87afc4a 100644 --- a/client/src/assets/player/index.ts +++ b/client/src/assets/player/index.ts | |||
@@ -1,2 +1,2 @@ | |||
1 | export * from './peertube-player-manager' | 1 | export * from './peertube-player-manager' |
2 | export * from './manager-options/manager-options.model' | 2 | export * from './types' |
diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts index ddb521a52..1b2a67c77 100644 --- a/client/src/assets/player/peertube-player-manager.ts +++ b/client/src/assets/player/peertube-player-manager.ts | |||
@@ -1,35 +1,34 @@ | |||
1 | import '@peertube/videojs-contextmenu' | 1 | import '@peertube/videojs-contextmenu' |
2 | import './upnext/end-card' | 2 | import './shared/upnext/end-card' |
3 | import './upnext/upnext-plugin' | 3 | import './shared/upnext/upnext-plugin' |
4 | import './stats/stats-card' | 4 | import './shared/stats/stats-card' |
5 | import './stats/stats-plugin' | 5 | import './shared/stats/stats-plugin' |
6 | import './bezels/bezels-plugin' | 6 | import './shared/bezels/bezels-plugin' |
7 | import './peertube-plugin' | 7 | import './shared/peertube/peertube-plugin' |
8 | import './peertube-resolutions-plugin' | 8 | import './shared/resolutions/peertube-resolutions-plugin' |
9 | import './control-bar/next-previous-video-button' | 9 | import './shared/control-bar/next-previous-video-button' |
10 | import './control-bar/p2p-info-button' | 10 | import './shared/control-bar/p2p-info-button' |
11 | import './control-bar/peertube-link-button' | 11 | import './shared/control-bar/peertube-link-button' |
12 | import './control-bar/peertube-load-progress-bar' | 12 | import './shared/control-bar/peertube-load-progress-bar' |
13 | import './control-bar/theater-button' | 13 | import './shared/control-bar/theater-button' |
14 | import './settings/resolution-menu-button' | 14 | import './shared/settings/resolution-menu-button' |
15 | import './settings/resolution-menu-item' | 15 | import './shared/settings/resolution-menu-item' |
16 | import './settings/settings-dialog' | 16 | import './shared/settings/settings-dialog' |
17 | import './settings/settings-menu-button' | 17 | import './shared/settings/settings-menu-button' |
18 | import './settings/settings-menu-item' | 18 | import './shared/settings/settings-menu-item' |
19 | import './settings/settings-panel' | 19 | import './shared/settings/settings-panel' |
20 | import './settings/settings-panel-child' | 20 | import './shared/settings/settings-panel-child' |
21 | import './playlist/playlist-plugin' | 21 | import './shared/playlist/playlist-plugin' |
22 | import './mobile/peertube-mobile-plugin' | 22 | import './shared/mobile/peertube-mobile-plugin' |
23 | import './mobile/peertube-mobile-buttons' | 23 | import './shared/mobile/peertube-mobile-buttons' |
24 | import './hotkeys/peertube-hotkeys-plugin' | 24 | import './shared/hotkeys/peertube-hotkeys-plugin' |
25 | import videojs from 'video.js' | 25 | import videojs from 'video.js' |
26 | import { PluginsManager } from '@root-helpers/plugins-manager' | 26 | import { PluginsManager } from '@root-helpers/plugins-manager' |
27 | import { ManagerOptionsBuilder } from './manager-options/manager-options-builder' | 27 | import { isMobile } from '@root-helpers/web-browser' |
28 | import { CommonOptions, PeertubePlayerManagerOptions, PlayerMode } from './manager-options/manager-options.model' | ||
29 | import { saveAverageBandwidth } from './peertube-player-local-storage' | 28 | import { saveAverageBandwidth } from './peertube-player-local-storage' |
30 | import { PlayerNetworkInfo } from './peertube-videojs-typings' | 29 | import { ManagerOptionsBuilder } from './shared/manager-options' |
31 | import { TranslationsManager } from './translations-manager' | 30 | import { TranslationsManager } from './translations-manager' |
32 | import { isMobile } from './utils' | 31 | import { CommonOptions, PeertubePlayerManagerOptions, PlayerMode, PlayerNetworkInfo } from './types' |
33 | 32 | ||
34 | // Change 'Playback Rate' to 'Speed' (smaller for our settings menu) | 33 | // Change 'Playback Rate' to 'Speed' (smaller for our settings menu) |
35 | (videojs.getComponent('PlaybackRateMenuButton') as any).prototype.controlText_ = 'Speed' | 34 | (videojs.getComponent('PlaybackRateMenuButton') as any).prototype.controlText_ = 'Speed' |
@@ -60,11 +59,11 @@ export class PeertubePlayerManager { | |||
60 | this.onPlayerChange = onPlayerChange | 59 | this.onPlayerChange = onPlayerChange |
61 | this.playerElementClassName = options.common.playerElement.className | 60 | this.playerElementClassName = options.common.playerElement.className |
62 | 61 | ||
63 | if (mode === 'webtorrent') await import('./webtorrent/webtorrent-plugin') | 62 | if (mode === 'webtorrent') await import('./shared/webtorrent/webtorrent-plugin') |
64 | if (mode === 'p2p-media-loader') { | 63 | if (mode === 'p2p-media-loader') { |
65 | const [ p2pMediaLoaderModule ] = await Promise.all([ | 64 | const [ p2pMediaLoaderModule ] = await Promise.all([ |
66 | import('@peertube/p2p-media-loader-hlsjs'), | 65 | import('@peertube/p2p-media-loader-hlsjs'), |
67 | import('./p2p-media-loader/p2p-media-loader-plugin') | 66 | import('./shared/p2p-media-loader/p2p-media-loader-plugin') |
68 | ]) | 67 | ]) |
69 | 68 | ||
70 | this.p2pMediaLoaderModule = p2pMediaLoaderModule | 69 | this.p2pMediaLoaderModule = p2pMediaLoaderModule |
@@ -174,7 +173,7 @@ export class PeertubePlayerManager { | |||
174 | 173 | ||
175 | this.rebuildAndUpdateVideoElement(currentPlayer, options.common) | 174 | this.rebuildAndUpdateVideoElement(currentPlayer, options.common) |
176 | 175 | ||
177 | await import('./webtorrent/webtorrent-plugin') | 176 | await import('./shared/webtorrent/webtorrent-plugin') |
178 | 177 | ||
179 | const newPlayer = await this.buildPlayer('webtorrent', options) | 178 | const newPlayer = await this.buildPlayer('webtorrent', options) |
180 | this.onPlayerChange(newPlayer) | 179 | this.onPlayerChange(newPlayer) |
diff --git a/client/src/assets/player/bezels/bezels-plugin.ts b/client/src/assets/player/shared/bezels/bezels-plugin.ts index ca88bc1f9..ca88bc1f9 100644 --- a/client/src/assets/player/bezels/bezels-plugin.ts +++ b/client/src/assets/player/shared/bezels/bezels-plugin.ts | |||
diff --git a/client/src/assets/player/shared/bezels/index.ts b/client/src/assets/player/shared/bezels/index.ts new file mode 100644 index 000000000..da861b07a --- /dev/null +++ b/client/src/assets/player/shared/bezels/index.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | export * from './bezels-plugin' | ||
2 | export * from './pause-bezel' | ||
diff --git a/client/src/assets/player/bezels/pause-bezel.ts b/client/src/assets/player/shared/bezels/pause-bezel.ts index 315964311..e35c39a5f 100644 --- a/client/src/assets/player/bezels/pause-bezel.ts +++ b/client/src/assets/player/shared/bezels/pause-bezel.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import videojs from 'video.js' | 1 | import videojs from 'video.js' |
2 | import { isMobile } from '../utils' | 2 | import { isMobile } from '@root-helpers/web-browser' |
3 | 3 | ||
4 | function getPauseBezel () { | 4 | function getPauseBezel () { |
5 | return ` | 5 | 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 index 000000000..9c56149ef --- /dev/null +++ b/client/src/assets/player/shared/common/index.ts | |||
@@ -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 index 000000000..da7dda0c7 --- /dev/null +++ b/client/src/assets/player/shared/common/utils.ts | |||
@@ -0,0 +1,66 @@ | |||
1 | import { VideoFile } from '@shared/models' | ||
2 | |||
3 | function toTitleCase (str: string) { | ||
4 | return str.charAt(0).toUpperCase() + str.slice(1) | ||
5 | } | ||
6 | |||
7 | // https://github.com/danrevah/ngx-pipes/blob/master/src/pipes/math/bytes.ts | ||
8 | // Don't import all Angular stuff, just copy the code with shame | ||
9 | const dictionaryBytes: Array<{max: number, type: string}> = [ | ||
10 | { max: 1024, type: 'B' }, | ||
11 | { max: 1048576, type: 'KB' }, | ||
12 | { max: 1073741824, type: 'MB' }, | ||
13 | { max: 1.0995116e12, type: 'GB' } | ||
14 | ] | ||
15 | function bytes (value: number) { | ||
16 | const format = dictionaryBytes.find(d => value < d.max) || dictionaryBytes[dictionaryBytes.length - 1] | ||
17 | const calc = Math.floor(value / (format.max / 1024)).toString() | ||
18 | |||
19 | return [ calc, format.type ] | ||
20 | } | ||
21 | |||
22 | function videoFileMaxByResolution (files: VideoFile[]) { | ||
23 | let max = files[0] | ||
24 | |||
25 | for (let i = 1; i < files.length; i++) { | ||
26 | const file = files[i] | ||
27 | if (max.resolution.id < file.resolution.id) max = file | ||
28 | } | ||
29 | |||
30 | return max | ||
31 | } | ||
32 | |||
33 | function videoFileMinByResolution (files: VideoFile[]) { | ||
34 | let min = files[0] | ||
35 | |||
36 | for (let i = 1; i < files.length; i++) { | ||
37 | const file = files[i] | ||
38 | if (min.resolution.id > file.resolution.id) min = file | ||
39 | } | ||
40 | |||
41 | return min | ||
42 | } | ||
43 | |||
44 | function getRtcConfig () { | ||
45 | return { | ||
46 | iceServers: [ | ||
47 | { | ||
48 | urls: 'stun:stun.stunprotocol.org' | ||
49 | }, | ||
50 | { | ||
51 | urls: 'stun:stun.framasoft.org' | ||
52 | } | ||
53 | ] | ||
54 | } | ||
55 | } | ||
56 | |||
57 | // --------------------------------------------------------------------------- | ||
58 | |||
59 | export { | ||
60 | getRtcConfig, | ||
61 | toTitleCase, | ||
62 | |||
63 | videoFileMaxByResolution, | ||
64 | videoFileMinByResolution, | ||
65 | bytes | ||
66 | } | ||
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 index 000000000..db5b8938d --- /dev/null +++ b/client/src/assets/player/shared/control-bar/index.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | export * from './next-previous-video-button' | ||
2 | export * from './p2p-info-button' | ||
3 | export * from './peertube-link-button' | ||
4 | export * from './peertube-load-progress-bar' | ||
5 | export * from './theater-button' | ||
diff --git a/client/src/assets/player/control-bar/next-previous-video-button.ts b/client/src/assets/player/shared/control-bar/next-previous-video-button.ts index fe17ce2ce..b7b986806 100644 --- a/client/src/assets/player/control-bar/next-previous-video-button.ts +++ b/client/src/assets/player/shared/control-bar/next-previous-video-button.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import videojs from 'video.js' | 1 | import videojs from 'video.js' |
2 | import { NextPreviousVideoButtonOptions } from '../peertube-videojs-typings' | 2 | import { NextPreviousVideoButtonOptions } from '../../types' |
3 | 3 | ||
4 | const Button = videojs.getComponent('Button') | 4 | const Button = videojs.getComponent('Button') |
5 | 5 | ||
diff --git a/client/src/assets/player/control-bar/p2p-info-button.ts b/client/src/assets/player/shared/control-bar/p2p-info-button.ts index 081dee1d3..36517e125 100644 --- a/client/src/assets/player/control-bar/p2p-info-button.ts +++ b/client/src/assets/player/shared/control-bar/p2p-info-button.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import videojs from 'video.js' | 1 | import videojs from 'video.js' |
2 | import { PeerTubeP2PInfoButtonOptions, PlayerNetworkInfo } from '../peertube-videojs-typings' | 2 | import { PeerTubeP2PInfoButtonOptions, PlayerNetworkInfo } from '../../types' |
3 | import { bytes } from '../utils' | 3 | import { bytes } from '../common' |
4 | 4 | ||
5 | const Button = videojs.getComponent('Button') | 5 | const Button = videojs.getComponent('Button') |
6 | class P2pInfoButton extends Button { | 6 | class P2pInfoButton extends Button { |
diff --git a/client/src/assets/player/control-bar/peertube-link-button.ts b/client/src/assets/player/shared/control-bar/peertube-link-button.ts index c49cee566..6d83263cc 100644 --- a/client/src/assets/player/control-bar/peertube-link-button.ts +++ b/client/src/assets/player/shared/control-bar/peertube-link-button.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import videojs from 'video.js' | 1 | import videojs from 'video.js' |
2 | import { buildVideoLink, decorateVideoLink } from '@shared/core-utils' | 2 | import { buildVideoLink, decorateVideoLink } from '@shared/core-utils' |
3 | import { PeerTubeLinkButtonOptions } from '../peertube-videojs-typings' | 3 | import { PeerTubeLinkButtonOptions } from '../../types' |
4 | 4 | ||
5 | const Button = videojs.getComponent('Button') | 5 | const Button = videojs.getComponent('Button') |
6 | class PeerTubeLinkButton extends Button { | 6 | class PeerTubeLinkButton extends Button { |
diff --git a/client/src/assets/player/control-bar/peertube-load-progress-bar.ts b/client/src/assets/player/shared/control-bar/peertube-load-progress-bar.ts index 623e70eb2..623e70eb2 100644 --- a/client/src/assets/player/control-bar/peertube-load-progress-bar.ts +++ b/client/src/assets/player/shared/control-bar/peertube-load-progress-bar.ts | |||
diff --git a/client/src/assets/player/control-bar/theater-button.ts b/client/src/assets/player/shared/control-bar/theater-button.ts index f862ee224..56c349d6b 100644 --- a/client/src/assets/player/control-bar/theater-button.ts +++ b/client/src/assets/player/shared/control-bar/theater-button.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import videojs from 'video.js' | 1 | import videojs from 'video.js' |
2 | import { saveTheaterInStore, getStoredTheater } from '../peertube-player-local-storage' | 2 | import { getStoredTheater, saveTheaterInStore } from '../../peertube-player-local-storage' |
3 | 3 | ||
4 | const Button = videojs.getComponent('Button') | 4 | const Button = videojs.getComponent('Button') |
5 | class TheaterButton extends Button { | 5 | 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 index 000000000..16e70a9c1 --- /dev/null +++ b/client/src/assets/player/shared/dock/index.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | export * from './peertube-dock-component' | ||
2 | export * from './peertube-dock-plugin' | ||
diff --git a/client/src/assets/player/dock/peertube-dock-component.ts b/client/src/assets/player/shared/dock/peertube-dock-component.ts index 183c7a00f..183c7a00f 100644 --- a/client/src/assets/player/dock/peertube-dock-component.ts +++ b/client/src/assets/player/shared/dock/peertube-dock-component.ts | |||
diff --git a/client/src/assets/player/dock/peertube-dock-plugin.ts b/client/src/assets/player/shared/dock/peertube-dock-plugin.ts index 245981692..245981692 100644 --- a/client/src/assets/player/dock/peertube-dock-plugin.ts +++ b/client/src/assets/player/shared/dock/peertube-dock-plugin.ts | |||
diff --git a/client/src/assets/player/shared/hotkeys/index.ts b/client/src/assets/player/shared/hotkeys/index.ts new file mode 100644 index 000000000..cc99a1ea8 --- /dev/null +++ b/client/src/assets/player/shared/hotkeys/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './peertube-hotkeys-plugin' | |||
diff --git a/client/src/assets/player/hotkeys/peertube-hotkeys-plugin.ts b/client/src/assets/player/shared/hotkeys/peertube-hotkeys-plugin.ts index 5920450bd..5920450bd 100644 --- a/client/src/assets/player/hotkeys/peertube-hotkeys-plugin.ts +++ b/client/src/assets/player/shared/hotkeys/peertube-hotkeys-plugin.ts | |||
diff --git a/client/src/assets/player/manager-options/control-bar-options-builder.ts b/client/src/assets/player/shared/manager-options/control-bar-options-builder.ts index 54e61c5d0..72a10eb26 100644 --- a/client/src/assets/player/manager-options/control-bar-options-builder.ts +++ b/client/src/assets/player/shared/manager-options/control-bar-options-builder.ts | |||
@@ -1,5 +1,10 @@ | |||
1 | import { NextPreviousVideoButtonOptions, PeerTubeLinkButtonOptions } from '../peertube-videojs-typings' | 1 | import { |
2 | import { CommonOptions, PeertubePlayerManagerOptions, PlayerMode } from './manager-options.model' | 2 | CommonOptions, |
3 | NextPreviousVideoButtonOptions, | ||
4 | PeerTubeLinkButtonOptions, | ||
5 | PeertubePlayerManagerOptions, | ||
6 | PlayerMode | ||
7 | } from '../../types' | ||
3 | 8 | ||
4 | export class ControlBarOptionsBuilder { | 9 | export class ControlBarOptionsBuilder { |
5 | private options: CommonOptions | 10 | private options: CommonOptions |
@@ -41,7 +46,7 @@ export class ControlBarOptionsBuilder { | |||
41 | muteToggle: {}, | 46 | muteToggle: {}, |
42 | volumeControl: {}, | 47 | volumeControl: {}, |
43 | 48 | ||
44 | settingsButton: this.getSettingsButton() | 49 | ...this.getSettingsButton() |
45 | }) | 50 | }) |
46 | 51 | ||
47 | if (this.options.peertubeLink === true) { | 52 | if (this.options.peertubeLink === true) { |
diff --git a/client/src/assets/player/manager-options/hls-options-builder.ts b/client/src/assets/player/shared/manager-options/hls-options-builder.ts index 9de23561b..e7f664fd4 100644 --- a/client/src/assets/player/manager-options/hls-options-builder.ts +++ b/client/src/assets/player/shared/manager-options/hls-options-builder.ts | |||
@@ -1,13 +1,13 @@ | |||
1 | import { HybridLoaderSettings } from '@peertube/p2p-media-loader-core' | 1 | import { HybridLoaderSettings } from '@peertube/p2p-media-loader-core' |
2 | import { HlsJsEngineSettings } from '@peertube/p2p-media-loader-hlsjs' | 2 | import { HlsJsEngineSettings } from '@peertube/p2p-media-loader-hlsjs' |
3 | import { LiveVideoLatencyMode } from '@shared/models' | 3 | import { LiveVideoLatencyMode } from '@shared/models' |
4 | import { getAverageBandwidthInStore } from '../../peertube-player-local-storage' | ||
5 | import { P2PMediaLoader, P2PMediaLoaderPluginOptions } from '../../types' | ||
6 | import { PeertubePlayerManagerOptions } from '../../types/manager-options' | ||
7 | import { getRtcConfig } from '../common' | ||
4 | import { RedundancyUrlManager } from '../p2p-media-loader/redundancy-url-manager' | 8 | import { RedundancyUrlManager } from '../p2p-media-loader/redundancy-url-manager' |
5 | import { segmentUrlBuilderFactory } from '../p2p-media-loader/segment-url-builder' | 9 | import { segmentUrlBuilderFactory } from '../p2p-media-loader/segment-url-builder' |
6 | import { segmentValidatorFactory } from '../p2p-media-loader/segment-validator' | 10 | import { segmentValidatorFactory } from '../p2p-media-loader/segment-validator' |
7 | import { getAverageBandwidthInStore } from '../peertube-player-local-storage' | ||
8 | import { P2PMediaLoader, P2PMediaLoaderPluginOptions } from '../peertube-videojs-typings' | ||
9 | import { getRtcConfig } from '../utils' | ||
10 | import { PeertubePlayerManagerOptions } from './manager-options.model' | ||
11 | 11 | ||
12 | export class HLSOptionsBuilder { | 12 | export class HLSOptionsBuilder { |
13 | 13 | ||
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 index 000000000..4934d8302 --- /dev/null +++ b/client/src/assets/player/shared/manager-options/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './manager-options-builder' | |||
diff --git a/client/src/assets/player/manager-options/manager-options-builder.ts b/client/src/assets/player/shared/manager-options/manager-options-builder.ts index 14bdb5d96..5dab1f7a9 100644 --- a/client/src/assets/player/manager-options/manager-options-builder.ts +++ b/client/src/assets/player/shared/manager-options/manager-options-builder.ts | |||
@@ -1,12 +1,13 @@ | |||
1 | import videojs from 'video.js' | 1 | import videojs from 'video.js' |
2 | import { copyToClipboard } from '@root-helpers/utils' | ||
3 | import { buildVideoOrPlaylistEmbed } from '@root-helpers/video' | ||
4 | import { isIOS, isSafari } from '@root-helpers/web-browser' | ||
2 | import { buildVideoLink, decorateVideoLink } from '@shared/core-utils' | 5 | import { buildVideoLink, decorateVideoLink } from '@shared/core-utils' |
3 | import { isDefaultLocale } from '@shared/core-utils/i18n' | 6 | import { isDefaultLocale } from '@shared/core-utils/i18n' |
4 | import { copyToClipboard } from '../../../root-helpers/utils' | 7 | import { VideoJSPluginOptions } from '../../types' |
5 | import { VideoJSPluginOptions } from '../peertube-videojs-typings' | 8 | import { CommonOptions, PeertubePlayerManagerOptions, PlayerMode } from '../../types/manager-options' |
6 | import { buildVideoOrPlaylistEmbed, isIOS, isSafari } from '../utils' | ||
7 | import { ControlBarOptionsBuilder } from './control-bar-options-builder' | 9 | import { ControlBarOptionsBuilder } from './control-bar-options-builder' |
8 | import { HLSOptionsBuilder } from './hls-options-builder' | 10 | import { HLSOptionsBuilder } from './hls-options-builder' |
9 | import { CommonOptions, PeertubePlayerManagerOptions, PlayerMode } from './manager-options.model' | ||
10 | import { WebTorrentOptionsBuilder } from './webtorrent-options-builder' | 11 | import { WebTorrentOptionsBuilder } from './webtorrent-options-builder' |
11 | 12 | ||
12 | export class ManagerOptionsBuilder { | 13 | export class ManagerOptionsBuilder { |
diff --git a/client/src/assets/player/manager-options/webtorrent-options-builder.ts b/client/src/assets/player/shared/manager-options/webtorrent-options-builder.ts index 303940b29..257cf1e05 100644 --- a/client/src/assets/player/manager-options/webtorrent-options-builder.ts +++ b/client/src/assets/player/shared/manager-options/webtorrent-options-builder.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { PeertubePlayerManagerOptions } from './manager-options.model' | 1 | import { PeertubePlayerManagerOptions } from '../../types' |
2 | 2 | ||
3 | export class WebTorrentOptionsBuilder { | 3 | export class WebTorrentOptionsBuilder { |
4 | 4 | ||
diff --git a/client/src/assets/player/shared/mobile/index.ts b/client/src/assets/player/shared/mobile/index.ts new file mode 100644 index 000000000..6f42b8db7 --- /dev/null +++ b/client/src/assets/player/shared/mobile/index.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | export * from './peertube-mobile-buttons' | ||
2 | export * from './peertube-mobile-plugin' | ||
diff --git a/client/src/assets/player/mobile/peertube-mobile-buttons.ts b/client/src/assets/player/shared/mobile/peertube-mobile-buttons.ts index 09cb98f2e..09cb98f2e 100644 --- a/client/src/assets/player/mobile/peertube-mobile-buttons.ts +++ b/client/src/assets/player/shared/mobile/peertube-mobile-buttons.ts | |||
diff --git a/client/src/assets/player/mobile/peertube-mobile-plugin.ts b/client/src/assets/player/shared/mobile/peertube-mobile-plugin.ts index 91dda7f94..91dda7f94 100644 --- a/client/src/assets/player/mobile/peertube-mobile-plugin.ts +++ b/client/src/assets/player/shared/mobile/peertube-mobile-plugin.ts | |||
diff --git a/client/src/assets/player/p2p-media-loader/hls-plugin.ts b/client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts index ccee2d90f..d0105fa36 100644 --- a/client/src/assets/player/p2p-media-loader/hls-plugin.ts +++ b/client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts | |||
@@ -3,7 +3,7 @@ | |||
3 | 3 | ||
4 | import Hlsjs, { ErrorData, HlsConfig, Level, LevelSwitchingData, ManifestParsedData } from 'hls.js' | 4 | import Hlsjs, { ErrorData, HlsConfig, Level, LevelSwitchingData, ManifestParsedData } from 'hls.js' |
5 | import videojs from 'video.js' | 5 | import videojs from 'video.js' |
6 | import { HlsjsConfigHandlerOptions, PeerTubeResolution, VideoJSTechHLS } from '../peertube-videojs-typings' | 6 | import { HlsjsConfigHandlerOptions, PeerTubeResolution, VideoJSTechHLS } from '../../types' |
7 | 7 | ||
8 | type ErrorCounts = { | 8 | type ErrorCounts = { |
9 | [ type: string ]: number | 9 | [ 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 index 000000000..02fe71e73 --- /dev/null +++ b/client/src/assets/player/shared/p2p-media-loader/index.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | export * from './hls-plugin' | ||
2 | export * from './p2p-media-loader-plugin' | ||
3 | export * from './redundancy-url-manager' | ||
4 | export * from './segment-url-builder' | ||
5 | export * from './segment-validator' | ||
diff --git a/client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts b/client/src/assets/player/shared/p2p-media-loader/p2p-media-loader-plugin.ts index 1d7a39b4e..5c0f0021f 100644 --- a/client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts +++ b/client/src/assets/player/shared/p2p-media-loader/p2p-media-loader-plugin.ts | |||
@@ -3,7 +3,7 @@ import videojs from 'video.js' | |||
3 | import { Events, Segment } from '@peertube/p2p-media-loader-core' | 3 | import { Events, Segment } from '@peertube/p2p-media-loader-core' |
4 | import { Engine, initHlsJsPlayer, initVideoJsContribHlsJsPlayer } from '@peertube/p2p-media-loader-hlsjs' | 4 | import { Engine, initHlsJsPlayer, initVideoJsContribHlsJsPlayer } from '@peertube/p2p-media-loader-hlsjs' |
5 | import { timeToInt } from '@shared/core-utils' | 5 | import { timeToInt } from '@shared/core-utils' |
6 | import { P2PMediaLoaderPluginOptions, PlayerNetworkInfo } from '../peertube-videojs-typings' | 6 | import { P2PMediaLoaderPluginOptions, PlayerNetworkInfo } from '../../types' |
7 | import { registerConfigPlugin, registerSourceHandler } from './hls-plugin' | 7 | import { registerConfigPlugin, registerSourceHandler } from './hls-plugin' |
8 | 8 | ||
9 | registerConfigPlugin(videojs) | 9 | registerConfigPlugin(videojs) |
diff --git a/client/src/assets/player/p2p-media-loader/redundancy-url-manager.ts b/client/src/assets/player/shared/p2p-media-loader/redundancy-url-manager.ts index abab8aa99..abab8aa99 100644 --- a/client/src/assets/player/p2p-media-loader/redundancy-url-manager.ts +++ b/client/src/assets/player/shared/p2p-media-loader/redundancy-url-manager.ts | |||
diff --git a/client/src/assets/player/p2p-media-loader/segment-url-builder.ts b/client/src/assets/player/shared/p2p-media-loader/segment-url-builder.ts index 9d324078a..9d324078a 100644 --- a/client/src/assets/player/p2p-media-loader/segment-url-builder.ts +++ b/client/src/assets/player/shared/p2p-media-loader/segment-url-builder.ts | |||
diff --git a/client/src/assets/player/p2p-media-loader/segment-validator.ts b/client/src/assets/player/shared/p2p-media-loader/segment-validator.ts index f7f83a8a4..f7f83a8a4 100644 --- a/client/src/assets/player/p2p-media-loader/segment-validator.ts +++ b/client/src/assets/player/shared/p2p-media-loader/segment-validator.ts | |||
diff --git a/client/src/assets/player/shared/peertube/index.ts b/client/src/assets/player/shared/peertube/index.ts new file mode 100644 index 000000000..ff4d5241b --- /dev/null +++ b/client/src/assets/player/shared/peertube/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './peertube-plugin' | |||
diff --git a/client/src/assets/player/peertube-plugin.ts b/client/src/assets/player/shared/peertube/peertube-plugin.ts index 4ffc9ce3e..1dc3e3de0 100644 --- a/client/src/assets/player/peertube-plugin.ts +++ b/client/src/assets/player/shared/peertube/peertube-plugin.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import debug from 'debug' | 1 | import debug from 'debug' |
2 | import videojs from 'video.js' | 2 | import videojs from 'video.js' |
3 | import { isMobile } from '@root-helpers/web-browser' | ||
3 | import { timeToInt } from '@shared/core-utils' | 4 | import { timeToInt } from '@shared/core-utils' |
4 | import { | 5 | import { |
5 | getStoredLastSubtitle, | 6 | getStoredLastSubtitle, |
@@ -9,10 +10,9 @@ import { | |||
9 | saveMuteInStore, | 10 | saveMuteInStore, |
10 | saveVideoWatchHistory, | 11 | saveVideoWatchHistory, |
11 | saveVolumeInStore | 12 | saveVolumeInStore |
12 | } from './peertube-player-local-storage' | 13 | } from '../../peertube-player-local-storage' |
13 | import { PeerTubePluginOptions, UserWatching, VideoJSCaption } from './peertube-videojs-typings' | 14 | import { PeerTubePluginOptions, UserWatching, VideoJSCaption } from '../../types' |
14 | import { SettingsButton } from './settings/settings-menu-button' | 15 | import { SettingsButton } from '../settings/settings-menu-button' |
15 | import { isMobile } from './utils' | ||
16 | 16 | ||
17 | const logger = debug('peertube:player:peertube') | 17 | const logger = debug('peertube:player:peertube') |
18 | 18 | ||
diff --git a/client/src/assets/player/shared/playlist/index.ts b/client/src/assets/player/shared/playlist/index.ts new file mode 100644 index 000000000..0be6e4d3c --- /dev/null +++ b/client/src/assets/player/shared/playlist/index.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export * from './playlist-button' | ||
2 | export * from './playlist-menu-item' | ||
3 | export * from './playlist-menu' | ||
4 | export * from './playlist-plugin' | ||
diff --git a/client/src/assets/player/playlist/playlist-button.ts b/client/src/assets/player/shared/playlist/playlist-button.ts index a7996ec60..6cfaf4158 100644 --- a/client/src/assets/player/playlist/playlist-button.ts +++ b/client/src/assets/player/shared/playlist/playlist-button.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import videojs from 'video.js' | 1 | import videojs from 'video.js' |
2 | import { PlaylistPluginOptions } from '../peertube-videojs-typings' | 2 | import { PlaylistPluginOptions } from '../../types' |
3 | import { PlaylistMenu } from './playlist-menu' | 3 | import { PlaylistMenu } from './playlist-menu' |
4 | 4 | ||
5 | const ClickableComponent = videojs.getComponent('ClickableComponent') | 5 | const ClickableComponent = videojs.getComponent('ClickableComponent') |
diff --git a/client/src/assets/player/playlist/playlist-menu-item.ts b/client/src/assets/player/shared/playlist/playlist-menu-item.ts index 2519a34c7..81b5acf30 100644 --- a/client/src/assets/player/playlist/playlist-menu-item.ts +++ b/client/src/assets/player/shared/playlist/playlist-menu-item.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import videojs from 'video.js' | 1 | import videojs from 'video.js' |
2 | import { secondsToTime } from '@shared/core-utils' | 2 | import { secondsToTime } from '@shared/core-utils' |
3 | import { VideoPlaylistElement } from '@shared/models' | 3 | import { VideoPlaylistElement } from '@shared/models' |
4 | import { PlaylistItemOptions } from '../peertube-videojs-typings' | 4 | import { PlaylistItemOptions } from '../../types' |
5 | 5 | ||
6 | const Component = videojs.getComponent('Component') | 6 | const Component = videojs.getComponent('Component') |
7 | 7 | ||
diff --git a/client/src/assets/player/playlist/playlist-menu.ts b/client/src/assets/player/shared/playlist/playlist-menu.ts index a2583047b..1ec9ac804 100644 --- a/client/src/assets/player/playlist/playlist-menu.ts +++ b/client/src/assets/player/shared/playlist/playlist-menu.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import videojs from 'video.js' | 1 | import videojs from 'video.js' |
2 | import { VideoPlaylistElement } from '@shared/models' | 2 | import { VideoPlaylistElement } from '@shared/models' |
3 | import { PlaylistPluginOptions } from '../peertube-videojs-typings' | 3 | import { PlaylistPluginOptions } from '../../types' |
4 | import { PlaylistMenuItem } from './playlist-menu-item' | 4 | import { PlaylistMenuItem } from './playlist-menu-item' |
5 | 5 | ||
6 | const Component = videojs.getComponent('Component') | 6 | const Component = videojs.getComponent('Component') |
diff --git a/client/src/assets/player/playlist/playlist-plugin.ts b/client/src/assets/player/shared/playlist/playlist-plugin.ts index b69d82e3c..44de0da5a 100644 --- a/client/src/assets/player/playlist/playlist-plugin.ts +++ b/client/src/assets/player/shared/playlist/playlist-plugin.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import videojs from 'video.js' | 1 | import videojs from 'video.js' |
2 | import { PlaylistPluginOptions } from '../peertube-videojs-typings' | 2 | import { PlaylistPluginOptions } from '../../types' |
3 | import { PlaylistButton } from './playlist-button' | 3 | import { PlaylistButton } from './playlist-button' |
4 | import { PlaylistMenu } from './playlist-menu' | 4 | import { PlaylistMenu } from './playlist-menu' |
5 | 5 | ||
@@ -20,7 +20,7 @@ class PlaylistPlugin extends Plugin { | |||
20 | }) | 20 | }) |
21 | 21 | ||
22 | this.playlistMenu = new PlaylistMenu(player, options) | 22 | this.playlistMenu = new PlaylistMenu(player, options) |
23 | this.playlistButton = new PlaylistButton(player, Object.assign({}, options, { playlistMenu: this.playlistMenu })) | 23 | this.playlistButton = new PlaylistButton(player, { ...options, playlistMenu: this.playlistMenu }) |
24 | 24 | ||
25 | player.addChild(this.playlistMenu, options) | 25 | player.addChild(this.playlistMenu, options) |
26 | player.addChild(this.playlistButton, options) | 26 | 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 index 000000000..e56473f43 --- /dev/null +++ b/client/src/assets/player/shared/resolutions/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './peertube-resolutions-plugin' | |||
diff --git a/client/src/assets/player/peertube-resolutions-plugin.ts b/client/src/assets/player/shared/resolutions/peertube-resolutions-plugin.ts index cc36f18f3..e7899ac71 100644 --- a/client/src/assets/player/peertube-resolutions-plugin.ts +++ b/client/src/assets/player/shared/resolutions/peertube-resolutions-plugin.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import videojs from 'video.js' | 1 | import videojs from 'video.js' |
2 | import { PeerTubeResolution } from './peertube-videojs-typings' | 2 | import { PeerTubeResolution } from '../../types' |
3 | 3 | ||
4 | const Plugin = videojs.getPlugin('plugin') | 4 | const Plugin = videojs.getPlugin('plugin') |
5 | 5 | ||
diff --git a/client/src/assets/player/shared/settings/index.ts b/client/src/assets/player/shared/settings/index.ts new file mode 100644 index 000000000..736d50c16 --- /dev/null +++ b/client/src/assets/player/shared/settings/index.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | export * from './resolution-menu-button' | ||
2 | export * from './resolution-menu-item' | ||
3 | export * from './settings-dialog' | ||
4 | export * from './settings-menu-button' | ||
5 | export * from './settings-menu-item' | ||
6 | export * from './settings-panel-child' | ||
7 | export * from './settings-panel' | ||
diff --git a/client/src/assets/player/settings/resolution-menu-button.ts b/client/src/assets/player/shared/settings/resolution-menu-button.ts index 8bd5b4f03..8bd5b4f03 100644 --- a/client/src/assets/player/settings/resolution-menu-button.ts +++ b/client/src/assets/player/shared/settings/resolution-menu-button.ts | |||
diff --git a/client/src/assets/player/settings/resolution-menu-item.ts b/client/src/assets/player/shared/settings/resolution-menu-item.ts index 6047f52f7..6047f52f7 100644 --- a/client/src/assets/player/settings/resolution-menu-item.ts +++ b/client/src/assets/player/shared/settings/resolution-menu-item.ts | |||
diff --git a/client/src/assets/player/settings/settings-dialog.ts b/client/src/assets/player/shared/settings/settings-dialog.ts index 8cd98967f..8cd98967f 100644 --- a/client/src/assets/player/settings/settings-dialog.ts +++ b/client/src/assets/player/shared/settings/settings-dialog.ts | |||
diff --git a/client/src/assets/player/settings/settings-menu-button.ts b/client/src/assets/player/shared/settings/settings-menu-button.ts index 6de390f4d..64866aab2 100644 --- a/client/src/assets/player/settings/settings-menu-button.ts +++ b/client/src/assets/player/shared/settings/settings-menu-button.ts | |||
@@ -1,9 +1,7 @@ | |||
1 | // Thanks to Yanko Shterev: https://github.com/yshterev/videojs-settings-menu | ||
2 | import { SettingsMenuItem } from './settings-menu-item' | ||
3 | import { toTitleCase } from '../utils' | ||
4 | import videojs from 'video.js' | 1 | import videojs from 'video.js' |
5 | 2 | import { toTitleCase } from '../common' | |
6 | import { SettingsDialog } from './settings-dialog' | 3 | import { SettingsDialog } from './settings-dialog' |
4 | import { SettingsMenuItem } from './settings-menu-item' | ||
7 | import { SettingsPanel } from './settings-panel' | 5 | import { SettingsPanel } from './settings-panel' |
8 | import { SettingsPanelChild } from './settings-panel-child' | 6 | import { SettingsPanelChild } from './settings-panel-child' |
9 | 7 | ||
diff --git a/client/src/assets/player/settings/settings-menu-item.ts b/client/src/assets/player/shared/settings/settings-menu-item.ts index 31d42c456..8d1819a2d 100644 --- a/client/src/assets/player/settings/settings-menu-item.ts +++ b/client/src/assets/player/shared/settings/settings-menu-item.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import videojs from 'video.js' | 1 | import videojs from 'video.js' |
2 | // Thanks to Yanko Shterev: https://github.com/yshterev/videojs-settings-menu | 2 | import { toTitleCase } from '../common' |
3 | import { toTitleCase } from '../utils' | ||
4 | import { SettingsDialog } from './settings-dialog' | 3 | import { SettingsDialog } from './settings-dialog' |
5 | import { SettingsButton } from './settings-menu-button' | 4 | import { SettingsButton } from './settings-menu-button' |
6 | import { SettingsPanel } from './settings-panel' | 5 | import { SettingsPanel } from './settings-panel' |
diff --git a/client/src/assets/player/settings/settings-panel-child.ts b/client/src/assets/player/shared/settings/settings-panel-child.ts index 161420c38..161420c38 100644 --- a/client/src/assets/player/settings/settings-panel-child.ts +++ b/client/src/assets/player/shared/settings/settings-panel-child.ts | |||
diff --git a/client/src/assets/player/settings/settings-panel.ts b/client/src/assets/player/shared/settings/settings-panel.ts index 28b579bdd..28b579bdd 100644 --- a/client/src/assets/player/settings/settings-panel.ts +++ b/client/src/assets/player/shared/settings/settings-panel.ts | |||
diff --git a/client/src/assets/player/shared/stats/index.ts b/client/src/assets/player/shared/stats/index.ts new file mode 100644 index 000000000..017ec044c --- /dev/null +++ b/client/src/assets/player/shared/stats/index.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | export * from './stats-card' | ||
2 | export * from './stats-plugin' | ||
diff --git a/client/src/assets/player/stats/stats-card.ts b/client/src/assets/player/shared/stats/stats-card.ts index e76a81a74..1bf631d2c 100644 --- a/client/src/assets/player/stats/stats-card.ts +++ b/client/src/assets/player/shared/stats/stats-card.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import videojs from 'video.js' | 1 | import videojs from 'video.js' |
2 | import { secondsToTime } from '@shared/core-utils' | 2 | import { secondsToTime } from '@shared/core-utils' |
3 | import { PlayerNetworkInfo as EventPlayerNetworkInfo } from '../peertube-videojs-typings' | 3 | import { PlayerNetworkInfo as EventPlayerNetworkInfo } from '../../types' |
4 | import { bytes } from '../utils' | 4 | import { bytes } from '../common' |
5 | 5 | ||
6 | interface StatsCardOptions extends videojs.ComponentOptions { | 6 | interface StatsCardOptions extends videojs.ComponentOptions { |
7 | videoUUID: string | 7 | videoUUID: string |
diff --git a/client/src/assets/player/stats/stats-plugin.ts b/client/src/assets/player/shared/stats/stats-plugin.ts index 8aad80e8a..8aad80e8a 100644 --- a/client/src/assets/player/stats/stats-plugin.ts +++ b/client/src/assets/player/shared/stats/stats-plugin.ts | |||
diff --git a/client/src/assets/player/upnext/end-card.ts b/client/src/assets/player/shared/upnext/end-card.ts index 61668e407..61668e407 100644 --- a/client/src/assets/player/upnext/end-card.ts +++ b/client/src/assets/player/shared/upnext/end-card.ts | |||
diff --git a/client/src/assets/player/shared/upnext/index.ts b/client/src/assets/player/shared/upnext/index.ts new file mode 100644 index 000000000..c63c5fd83 --- /dev/null +++ b/client/src/assets/player/shared/upnext/index.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | export * from './end-card' | ||
2 | export * from './upnext-plugin' | ||
diff --git a/client/src/assets/player/upnext/upnext-plugin.ts b/client/src/assets/player/shared/upnext/upnext-plugin.ts index db969024d..db969024d 100644 --- a/client/src/assets/player/upnext/upnext-plugin.ts +++ b/client/src/assets/player/shared/upnext/upnext-plugin.ts | |||
diff --git a/client/src/assets/player/webtorrent/peertube-chunk-store.ts b/client/src/assets/player/shared/webtorrent/peertube-chunk-store.ts index 81378c277..81378c277 100644 --- a/client/src/assets/player/webtorrent/peertube-chunk-store.ts +++ b/client/src/assets/player/shared/webtorrent/peertube-chunk-store.ts | |||
diff --git a/client/src/assets/player/webtorrent/video-renderer.ts b/client/src/assets/player/shared/webtorrent/video-renderer.ts index 9b80fea2c..9b80fea2c 100644 --- a/client/src/assets/player/webtorrent/video-renderer.ts +++ b/client/src/assets/player/shared/webtorrent/video-renderer.ts | |||
diff --git a/client/src/assets/player/webtorrent/webtorrent-plugin.ts b/client/src/assets/player/shared/webtorrent/webtorrent-plugin.ts index 4bcb2766a..b48203148 100644 --- a/client/src/assets/player/webtorrent/webtorrent-plugin.ts +++ b/client/src/assets/player/shared/webtorrent/webtorrent-plugin.ts | |||
@@ -1,10 +1,11 @@ | |||
1 | import videojs from 'video.js' | 1 | import videojs from 'video.js' |
2 | import * as WebTorrent from 'webtorrent' | 2 | import * as WebTorrent from 'webtorrent' |
3 | import { isIOS } from '@root-helpers/web-browser' | ||
3 | import { timeToInt } from '@shared/core-utils' | 4 | import { timeToInt } from '@shared/core-utils' |
4 | import { VideoFile } from '@shared/models' | 5 | import { VideoFile } from '@shared/models' |
5 | import { getAverageBandwidthInStore, getStoredMute, getStoredVolume, saveAverageBandwidth } from '../peertube-player-local-storage' | 6 | import { getAverageBandwidthInStore, getStoredMute, getStoredVolume, saveAverageBandwidth } from '../../peertube-player-local-storage' |
6 | import { PeerTubeResolution, PlayerNetworkInfo, WebtorrentPluginOptions } from '../peertube-videojs-typings' | 7 | import { PeerTubeResolution, PlayerNetworkInfo, WebtorrentPluginOptions } from '../../types' |
7 | import { getRtcConfig, isIOS, videoFileMaxByResolution, videoFileMinByResolution } from '../utils' | 8 | import { getRtcConfig, videoFileMaxByResolution, videoFileMinByResolution } from '../common' |
8 | import { PeertubeChunkStore } from './peertube-chunk-store' | 9 | import { PeertubeChunkStore } from './peertube-chunk-store' |
9 | import { renderVideo } from './video-renderer' | 10 | import { renderVideo } from './video-renderer' |
10 | 11 | ||
diff --git a/client/src/assets/player/types/index.ts b/client/src/assets/player/types/index.ts new file mode 100644 index 000000000..b73e0b3cb --- /dev/null +++ b/client/src/assets/player/types/index.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | export * from './manager-options' | ||
2 | export * from './peertube-videojs-typings' | ||
diff --git a/client/src/assets/player/manager-options/manager-options.model.ts b/client/src/assets/player/types/manager-options.ts index 0b0f8b435..b3ad7e337 100644 --- a/client/src/assets/player/manager-options/manager-options.model.ts +++ b/client/src/assets/player/types/manager-options.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { PluginsManager } from '@root-helpers/plugins-manager' | 1 | import { PluginsManager } from '@root-helpers/plugins-manager' |
2 | import { LiveVideoLatencyMode, VideoFile } from '@shared/models' | 2 | import { LiveVideoLatencyMode, VideoFile } from '@shared/models' |
3 | import { PlaylistPluginOptions, UserWatching, VideoJSCaption } from '../peertube-videojs-typings' | 3 | import { PlaylistPluginOptions, UserWatching, VideoJSCaption } from './peertube-videojs-typings' |
4 | 4 | ||
5 | export type PlayerMode = 'webtorrent' | 'p2p-media-loader' | 5 | export type PlayerMode = 'webtorrent' | 'p2p-media-loader' |
6 | 6 | ||
diff --git a/client/src/assets/player/peertube-videojs-typings.ts b/client/src/assets/player/types/peertube-videojs-typings.ts index fcaa8a9c3..d9a388681 100644 --- a/client/src/assets/player/peertube-videojs-typings.ts +++ b/client/src/assets/player/types/peertube-videojs-typings.ts | |||
@@ -2,18 +2,18 @@ import { HlsConfig, Level } from 'hls.js' | |||
2 | import videojs from 'video.js' | 2 | import videojs from 'video.js' |
3 | import { Engine } from '@peertube/p2p-media-loader-hlsjs' | 3 | import { Engine } from '@peertube/p2p-media-loader-hlsjs' |
4 | import { VideoFile, VideoPlaylist, VideoPlaylistElement } from '@shared/models' | 4 | import { VideoFile, VideoPlaylist, VideoPlaylistElement } from '@shared/models' |
5 | import { PeerTubeDockPluginOptions } from './dock/peertube-dock-plugin' | 5 | import { PeerTubeDockPluginOptions } from '../shared/dock/peertube-dock-plugin' |
6 | import { PlayerMode } from './manager-options/manager-options.model' | 6 | import { Html5Hlsjs } from '../shared/p2p-media-loader/hls-plugin' |
7 | import { Html5Hlsjs } from './p2p-media-loader/hls-plugin' | 7 | import { P2pMediaLoaderPlugin } from '../shared/p2p-media-loader/p2p-media-loader-plugin' |
8 | import { P2pMediaLoaderPlugin } from './p2p-media-loader/p2p-media-loader-plugin' | 8 | import { RedundancyUrlManager } from '../shared/p2p-media-loader/redundancy-url-manager' |
9 | import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager' | 9 | import { PeerTubePlugin } from '../shared/peertube/peertube-plugin' |
10 | import { PeerTubePlugin } from './peertube-plugin' | 10 | import { PlaylistPlugin } from '../shared/playlist/playlist-plugin' |
11 | import { PeerTubeResolutionsPlugin } from './peertube-resolutions-plugin' | 11 | import { PeerTubeResolutionsPlugin } from '../shared/resolutions/peertube-resolutions-plugin' |
12 | import { PlaylistPlugin } from './playlist/playlist-plugin' | 12 | import { StatsCardOptions } from '../shared/stats/stats-card' |
13 | import { StatsCardOptions } from './stats/stats-card' | 13 | import { StatsForNerdsPlugin } from '../shared/stats/stats-plugin' |
14 | import { StatsForNerdsPlugin } from './stats/stats-plugin' | 14 | import { EndCardOptions } from '../shared/upnext/end-card' |
15 | import { EndCardOptions } from './upnext/end-card' | 15 | import { WebTorrentPlugin } from '../shared/webtorrent/webtorrent-plugin' |
16 | import { WebTorrentPlugin } from './webtorrent/webtorrent-plugin' | 16 | import { PlayerMode } from './manager-options' |
17 | 17 | ||
18 | declare module 'video.js' { | 18 | declare module 'video.js' { |
19 | 19 | ||
diff --git a/client/src/root-helpers/index.ts b/client/src/root-helpers/index.ts index aa3b442dd..3b95b4b99 100644 --- a/client/src/root-helpers/index.ts +++ b/client/src/root-helpers/index.ts | |||
@@ -3,5 +3,6 @@ export * from './bytes' | |||
3 | export * from './images' | 3 | export * from './images' |
4 | export * from './local-storage-utils' | 4 | export * from './local-storage-utils' |
5 | export * from './peertube-web-storage' | 5 | export * from './peertube-web-storage' |
6 | export * from './utils' | ||
7 | export * from './plugins-manager' | 6 | export * from './plugins-manager' |
7 | export * from './utils' | ||
8 | export * from './video' | ||
diff --git a/client/src/root-helpers/video.ts b/client/src/root-helpers/video.ts new file mode 100644 index 000000000..4290992aa --- /dev/null +++ b/client/src/root-helpers/video.ts | |||
@@ -0,0 +1,33 @@ | |||
1 | import { HTMLServerConfig, Video } from '@shared/models' | ||
2 | |||
3 | function buildVideoOrPlaylistEmbed (embedUrl: string, embedTitle: string) { | ||
4 | const iframe = document.createElement('iframe') | ||
5 | |||
6 | iframe.title = embedTitle | ||
7 | iframe.width = '560' | ||
8 | iframe.height = '315' | ||
9 | iframe.src = embedUrl | ||
10 | iframe.frameBorder = '0' | ||
11 | iframe.allowFullscreen = true | ||
12 | iframe.sandbox.add('allow-same-origin', 'allow-scripts', 'allow-popups') | ||
13 | |||
14 | return iframe.outerHTML | ||
15 | } | ||
16 | |||
17 | function isP2PEnabled (video: Video, config: HTMLServerConfig, userP2PEnabled: boolean) { | ||
18 | if (video.isLocal && config.tracker.enabled === false) return false | ||
19 | if (isWebRTCDisabled()) return false | ||
20 | |||
21 | return userP2PEnabled | ||
22 | } | ||
23 | |||
24 | export { | ||
25 | buildVideoOrPlaylistEmbed, | ||
26 | isP2PEnabled | ||
27 | } | ||
28 | |||
29 | // --------------------------------------------------------------------------- | ||
30 | |||
31 | function isWebRTCDisabled () { | ||
32 | return !!((window as any).RTCPeerConnection || (window as any).mozRTCPeerConnection || (window as any).webkitRTCPeerConnection) === false | ||
33 | } | ||
diff --git a/client/src/root-helpers/web-browser.ts b/client/src/root-helpers/web-browser.ts new file mode 100644 index 000000000..9dade20e8 --- /dev/null +++ b/client/src/root-helpers/web-browser.ts | |||
@@ -0,0 +1,24 @@ | |||
1 | function isIOS () { | ||
2 | if (/iPad|iPhone|iPod/.test(navigator.platform)) { | ||
3 | return true | ||
4 | } | ||
5 | |||
6 | // Detect iPad Desktop mode | ||
7 | return !!(navigator.maxTouchPoints && | ||
8 | navigator.maxTouchPoints > 2 && | ||
9 | navigator.platform.includes('MacIntel')) | ||
10 | } | ||
11 | |||
12 | function isSafari () { | ||
13 | return /^((?!chrome|android).)*safari/i.test(navigator.userAgent) | ||
14 | } | ||
15 | |||
16 | function isMobile () { | ||
17 | return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent) | ||
18 | } | ||
19 | |||
20 | export { | ||
21 | isIOS, | ||
22 | isSafari, | ||
23 | isMobile | ||
24 | } | ||
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index 9e4d87911..55c26ec3b 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import './embed.scss' | 1 | import './embed.scss' |
2 | import '../../assets/player/dock/peertube-dock-component' | 2 | import '../../assets/player/shared/dock/peertube-dock-component' |
3 | import '../../assets/player/dock/peertube-dock-plugin' | 3 | import '../../assets/player/shared/dock/peertube-dock-plugin' |
4 | import videojs from 'video.js' | 4 | import videojs from 'video.js' |
5 | import { peertubeTranslate } from '../../../../shared/core-utils/i18n' | 5 | import { peertubeTranslate } from '../../../../shared/core-utils/i18n' |
6 | import { | 6 | import { |
@@ -17,15 +17,14 @@ import { | |||
17 | VideoPlaylistElement, | 17 | VideoPlaylistElement, |
18 | VideoStreamingPlaylistType | 18 | VideoStreamingPlaylistType |
19 | } from '../../../../shared/models' | 19 | } from '../../../../shared/models' |
20 | import { P2PMediaLoaderOptions, PeertubePlayerManagerOptions, PlayerMode } from '../../assets/player' | 20 | import { P2PMediaLoaderOptions, PeertubePlayerManagerOptions, PlayerMode, VideoJSCaption } from '../../assets/player' |
21 | import { VideoJSCaption } from '../../assets/player/peertube-videojs-typings' | ||
22 | import { TranslationsManager } from '../../assets/player/translations-manager' | 21 | import { TranslationsManager } from '../../assets/player/translations-manager' |
23 | import { isP2PEnabled } from '../../assets/player/utils' | ||
24 | import { getBoolOrDefault } from '../../root-helpers/local-storage-utils' | 22 | import { getBoolOrDefault } from '../../root-helpers/local-storage-utils' |
25 | import { peertubeLocalStorage } from '../../root-helpers/peertube-web-storage' | 23 | import { peertubeLocalStorage } from '../../root-helpers/peertube-web-storage' |
26 | import { PluginsManager } from '../../root-helpers/plugins-manager' | 24 | import { PluginsManager } from '../../root-helpers/plugins-manager' |
27 | import { UserLocalStorageKeys, UserTokens } from '../../root-helpers/users' | 25 | import { UserLocalStorageKeys, UserTokens } from '../../root-helpers/users' |
28 | import { objectToUrlEncoded } from '../../root-helpers/utils' | 26 | import { objectToUrlEncoded } from '../../root-helpers/utils' |
27 | import { isP2PEnabled } from '../../root-helpers/video' | ||
29 | import { RegisterClientHelpers } from '../../types/register-client-option.model' | 28 | import { RegisterClientHelpers } from '../../types/register-client-option.model' |
30 | import { PeerTubeEmbedApi } from './embed-api' | 29 | import { PeerTubeEmbedApi } from './embed-api' |
31 | 30 | ||