aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player')
-rw-r--r--client/src/assets/player/p2p-media-loader/segment-validator.ts9
-rw-r--r--client/src/assets/player/peertube-player-manager.ts4
2 files changed, 9 insertions, 4 deletions
diff --git a/client/src/assets/player/p2p-media-loader/segment-validator.ts b/client/src/assets/player/p2p-media-loader/segment-validator.ts
index 9add35184..844956d6a 100644
--- a/client/src/assets/player/p2p-media-loader/segment-validator.ts
+++ b/client/src/assets/player/p2p-media-loader/segment-validator.ts
@@ -6,11 +6,14 @@ type SegmentsJSON = { [filename: string]: string | { [byterange: string]: string
6 6
7const maxRetries = 3 7const maxRetries = 3
8 8
9function segmentValidatorFactory (segmentsSha256Url: string) { 9function segmentValidatorFactory (segmentsSha256Url: string, isLive: boolean) {
10 let segmentsJSON = fetchSha256Segments(segmentsSha256Url) 10 let segmentsJSON = fetchSha256Segments(segmentsSha256Url)
11 const regex = /bytes=(\d+)-(\d+)/ 11 const regex = /bytes=(\d+)-(\d+)/
12 12
13 return async function segmentValidator (segment: Segment, retry = 1) { 13 return async function segmentValidator (segment: Segment, retry = 1) {
14 // Wait for hash generation from the server
15 if (isLive) await wait(1000)
16
14 const filename = basename(segment.url) 17 const filename = basename(segment.url)
15 18
16 const segmentValue = (await segmentsJSON)[filename] 19 const segmentValue = (await segmentsJSON)[filename]
@@ -20,10 +23,10 @@ function segmentValidatorFactory (segmentsSha256Url: string) {
20 } 23 }
21 24
22 if (!segmentValue) { 25 if (!segmentValue) {
23 await wait(1000)
24
25 console.log('Refetching sha segments for %s.', filename) 26 console.log('Refetching sha segments for %s.', filename)
26 27
28 await wait(1000)
29
27 segmentsJSON = fetchSha256Segments(segmentsSha256Url) 30 segmentsJSON = fetchSha256Segments(segmentsSha256Url)
28 await segmentValidator(segment, retry + 1) 31 await segmentValidator(segment, retry + 1)
29 32
diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts
index c1953043e..da23c59a7 100644
--- a/client/src/assets/player/peertube-player-manager.ts
+++ b/client/src/assets/player/peertube-player-manager.ts
@@ -98,6 +98,8 @@ export interface CommonOptions extends CustomizationOptions {
98 videoViewUrl: string 98 videoViewUrl: string
99 embedUrl: string 99 embedUrl: string
100 100
101 isLive: boolean
102
101 language?: string 103 language?: string
102 104
103 videoCaptions: VideoJSCaption[] 105 videoCaptions: VideoJSCaption[]
@@ -323,7 +325,7 @@ export class PeertubePlayerManager {
323 const p2pMediaLoaderConfig = { 325 const p2pMediaLoaderConfig = {
324 loader: { 326 loader: {
325 trackerAnnounce, 327 trackerAnnounce,
326 segmentValidator: segmentValidatorFactory(options.p2pMediaLoader.segmentsSha256Url), 328 segmentValidator: segmentValidatorFactory(options.p2pMediaLoader.segmentsSha256Url, options.common.isLive),
327 rtcConfig: getRtcConfig(), 329 rtcConfig: getRtcConfig(),
328 requiredSegmentsPriority: 1, 330 requiredSegmentsPriority: 1,
329 segmentUrlBuilder: segmentUrlBuilderFactory(redundancyUrlManager), 331 segmentUrlBuilder: segmentUrlBuilderFactory(redundancyUrlManager),