- const videojsOptions = getVideojsOptions({
- autoplay: this.isAutoplay(),
- inactivityTimeout: 2500,
- videoFiles: this.video.files,
- videoCaptions: playerCaptions,
- playerElement: this.playerElement,
- videoViewUrl: this.video.privacy.id !== VideoPrivacy.PRIVATE ? this.videoService.getVideoViewUrl(this.video.uuid) : null,
- videoDuration: this.video.duration,
- enableHotkeys: true,
- peertubeLink: false,
- poster: this.video.previewUrl,
- startTime,
- subtitle: urlOptions.subtitle,
- theaterMode: true,
- language: this.localeId,
-
- userWatching: this.user && this.user.videosHistoryEnabled === true ? {
- url: this.videoService.getUserWatchingVideoUrl(this.video.uuid),
- authorizationHeader: this.authService.getRequestHeaderValue()
- } : undefined
- })
+ const options: PeertubePlayerManagerOptions = {
+ common: {
+ autoplay: this.isAutoplay(),
+
+ playerElement: this.playerElement,
+ onPlayerElementChange: (element: HTMLVideoElement) => this.playerElement = element,
+
+ videoDuration: this.video.duration,
+ enableHotkeys: true,
+ inactivityTimeout: 2500,
+ poster: this.video.previewUrl,
+
+ startTime,
+ stopTime: urlOptions.stopTime,
+ controls: urlOptions.controls,
+ muted: urlOptions.muted,
+ loop: urlOptions.loop,
+ subtitle: urlOptions.subtitle,
+
+ peertubeLink: urlOptions.peertubeLink,
+
+ theaterMode: true,
+ captions: videoCaptions.length !== 0,
+
+ videoViewUrl: this.video.privacy.id !== VideoPrivacy.PRIVATE
+ ? this.videoService.getVideoViewUrl(this.video.uuid)
+ : null,
+ embedUrl: this.video.embedUrl,
+
+ language: this.localeId,
+
+ userWatching: this.user && this.user.videosHistoryEnabled === true ? {
+ url: this.videoService.getUserWatchingVideoUrl(this.video.uuid),
+ authorizationHeader: this.authService.getRequestHeaderValue()
+ } : undefined,
+
+ serverUrl: environment.apiUrl,
+
+ videoCaptions: playerCaptions
+ },
+
+ webtorrent: {
+ videoFiles: this.video.files
+ }
+ }
+
+ let mode: PlayerMode
+
+ if (urlOptions.playerMode) {
+ if (urlOptions.playerMode === 'p2p-media-loader') mode = 'p2p-media-loader'
+ else mode = 'webtorrent'
+ } else {
+ if (this.video.hasHlsPlaylist()) mode = 'p2p-media-loader'
+ else mode = 'webtorrent'
+ }
+
+ if (mode === 'p2p-media-loader') {
+ const hlsPlaylist = this.video.getHlsPlaylist()
+
+ const p2pMediaLoader = {
+ playlistUrl: hlsPlaylist.playlistUrl,
+ segmentsSha256Url: hlsPlaylist.segmentsSha256Url,
+ redundancyBaseUrls: hlsPlaylist.redundancies.map(r => r.baseUrl),
+ trackerAnnounce: this.video.trackerUrls,
+ videoFiles: hlsPlaylist.files
+ } as P2PMediaLoaderOptions