aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/p2p-media-loader
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player/p2p-media-loader')
-rw-r--r--client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts12
1 files changed, 11 insertions, 1 deletions
diff --git a/client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts b/client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts
index 4dbfda300..bbd3e008d 100644
--- a/client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts
+++ b/client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts
@@ -4,6 +4,7 @@ import * as videojs from 'video.js'
4import { P2PMediaLoaderPluginOptions, PlayerNetworkInfo, VideoJSComponentInterface } from '../peertube-videojs-typings' 4import { P2PMediaLoaderPluginOptions, PlayerNetworkInfo, VideoJSComponentInterface } from '../peertube-videojs-typings'
5import { Engine, initHlsJsPlayer, initVideoJsContribHlsJsPlayer } from 'p2p-media-loader-hlsjs' 5import { Engine, initHlsJsPlayer, initVideoJsContribHlsJsPlayer } from 'p2p-media-loader-hlsjs'
6import { Events } from 'p2p-media-loader-core' 6import { Events } from 'p2p-media-loader-core'
7import { timeToInt } from '../utils'
7 8
8// videojs-hlsjs-plugin needs videojs in window 9// videojs-hlsjs-plugin needs videojs in window
9window['videojs'] = videojs 10window['videojs'] = videojs
@@ -32,6 +33,7 @@ class P2pMediaLoaderPlugin extends Plugin {
32 totalDownload: 0, 33 totalDownload: 0,
33 totalUpload: 0 34 totalUpload: 0
34 } 35 }
36 private startTime: number
35 37
36 private networkInfoInterval: any 38 private networkInfoInterval: any
37 39
@@ -54,12 +56,14 @@ class P2pMediaLoaderPlugin extends Plugin {
54 56
55 initVideoJsContribHlsJsPlayer(player) 57 initVideoJsContribHlsJsPlayer(player)
56 58
59 this.startTime = timeToInt(options.startTime)
60
57 player.src({ 61 player.src({
58 type: options.type, 62 type: options.type,
59 src: options.src 63 src: options.src
60 }) 64 })
61 65
62 player.on('play', () => { 66 player.one('play', () => {
63 player.addClass('vjs-has-big-play-button-clicked') 67 player.addClass('vjs-has-big-play-button-clicked')
64 }) 68 })
65 69
@@ -92,6 +96,12 @@ class P2pMediaLoaderPlugin extends Plugin {
92 this.statsP2PBytes.numPeers = 1 + this.options.redundancyBaseUrls.length 96 this.statsP2PBytes.numPeers = 1 + this.options.redundancyBaseUrls.length
93 97
94 this.runStats() 98 this.runStats()
99
100 this.hlsjs.on('hlsLevelLoaded', () => {
101 if (this.startTime) this.player.currentTime(this.startTime)
102
103 this.hlsjs.off('hlsLevelLoaded', this)
104 })
95 } 105 }
96 106
97 private runStats () { 107 private runStats () {