diff options
Diffstat (limited to 'client/src/assets/player/p2p-media-loader')
-rw-r--r-- | client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts | 12 |
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' | |||
4 | import { P2PMediaLoaderPluginOptions, PlayerNetworkInfo, VideoJSComponentInterface } from '../peertube-videojs-typings' | 4 | import { P2PMediaLoaderPluginOptions, PlayerNetworkInfo, VideoJSComponentInterface } from '../peertube-videojs-typings' |
5 | import { Engine, initHlsJsPlayer, initVideoJsContribHlsJsPlayer } from 'p2p-media-loader-hlsjs' | 5 | import { Engine, initHlsJsPlayer, initVideoJsContribHlsJsPlayer } from 'p2p-media-loader-hlsjs' |
6 | import { Events } from 'p2p-media-loader-core' | 6 | import { Events } from 'p2p-media-loader-core' |
7 | import { timeToInt } from '../utils' | ||
7 | 8 | ||
8 | // videojs-hlsjs-plugin needs videojs in window | 9 | // videojs-hlsjs-plugin needs videojs in window |
9 | window['videojs'] = videojs | 10 | window['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 () { |