]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/assets/player/peertube-player-manager.ts
Improve parse log with sql
[github/Chocobozzz/PeerTube.git] / client / src / assets / player / peertube-player-manager.ts
index af044c864fb3f4e6c02151d1db06c65340f854eb..fcf0d0f4158eb42c573c5523d1635c1167386f63 100644 (file)
@@ -35,7 +35,8 @@ import {
   VideoJSPluginOptions
 } from './peertube-videojs-typings'
 import { TranslationsManager } from './translations-manager'
-import { buildVideoOrPlaylistEmbed, buildVideoLink, copyToClipboard, getRtcConfig, isSafari, isIOS } from './utils'
+import { buildVideoOrPlaylistEmbed, buildVideoLink, getRtcConfig, isSafari, isIOS } from './utils'
+import { copyToClipboard } from '../../root-helpers/utils'
 
 // Change 'Playback Rate' to 'Speed' (smaller for our settings menu)
 (videojs.getComponent('PlaybackRateMenuButton') as any).prototype.controlText_ = 'Speed'
@@ -98,6 +99,8 @@ export interface CommonOptions extends CustomizationOptions {
   videoViewUrl: string
   embedUrl: string
 
+  isLive: boolean
+
   language?: string
 
   videoCaptions: VideoJSCaption[]
@@ -220,13 +223,14 @@ export class PeertubePlayerManager {
     const plugins: VideoJSPluginOptions = {
       peertube: {
         mode,
-        autoplay, // Use peertube plugin autoplay because we get the file by webtorrent
+        autoplay, // Use peertube plugin autoplay because we could get the file by webtorrent
         videoViewUrl: commonOptions.videoViewUrl,
         videoDuration: commonOptions.videoDuration,
         userWatching: commonOptions.userWatching,
         subtitle: commonOptions.subtitle,
         videoCaptions: commonOptions.videoCaptions,
-        stopTime: commonOptions.stopTime
+        stopTime: commonOptions.stopTime,
+        isLive: commonOptions.isLive
       }
     }
 
@@ -323,9 +327,9 @@ export class PeertubePlayerManager {
     const p2pMediaLoaderConfig = {
       loader: {
         trackerAnnounce,
-        segmentValidator: segmentValidatorFactory(options.p2pMediaLoader.segmentsSha256Url),
+        segmentValidator: segmentValidatorFactory(options.p2pMediaLoader.segmentsSha256Url, options.common.isLive),
         rtcConfig: getRtcConfig(),
-        requiredSegmentsPriority: 5,
+        requiredSegmentsPriority: 1,
         segmentUrlBuilder: segmentUrlBuilderFactory(redundancyUrlManager),
         useP2P: getStoredP2PEnabled(),
         consumeOnly
@@ -339,10 +343,8 @@ export class PeertubePlayerManager {
         const resolution = Math.min(level.height || 0, level.width || 0)
 
         const file = p2pMediaLoaderOptions.videoFiles.find(f => f.resolution.id === resolution)
-        if (!file) {
-          console.error('Cannot find video file for level %d.', level.height)
-          return level.height
-        }
+        // We don't have files for live videos
+        if (!file) return level.height
 
         let label = file.resolution.label
         if (file.fps >= 50) label += file.fps
@@ -353,7 +355,7 @@ export class PeertubePlayerManager {
         hlsjsConfig: {
           capLevelToPlayerSize: true,
           autoStartLoad: false,
-          liveSyncDurationCount: 7,
+          liveSyncDurationCount: 5,
           loader: new p2pMediaLoaderModule.Engine(p2pMediaLoaderConfig).createLoaderClass()
         }
       }