aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/webtorrent-plugin.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-01-24 10:16:30 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-02-11 09:13:02 +0100
commit3b6f205c34bb931de0323581edf991ca33256e6b (patch)
treef6ba40b7c666e38ff9c321906f04cb2c2630163e /client/src/assets/player/webtorrent-plugin.ts
parent2adfc7ea9a1f858db874df9fe322e7ae833db77c (diff)
downloadPeerTube-3b6f205c34bb931de0323581edf991ca33256e6b.tar.gz
PeerTube-3b6f205c34bb931de0323581edf991ca33256e6b.tar.zst
PeerTube-3b6f205c34bb931de0323581edf991ca33256e6b.zip
Correctly implement p2p-media-loader
Diffstat (limited to 'client/src/assets/player/webtorrent-plugin.ts')
-rw-r--r--client/src/assets/player/webtorrent-plugin.ts26
1 files changed, 14 insertions, 12 deletions
diff --git a/client/src/assets/player/webtorrent-plugin.ts b/client/src/assets/player/webtorrent-plugin.ts
index c3d990aed..47f169e24 100644
--- a/client/src/assets/player/webtorrent-plugin.ts
+++ b/client/src/assets/player/webtorrent-plugin.ts
@@ -5,7 +5,7 @@ import * as videojs from 'video.js'
5import * as WebTorrent from 'webtorrent' 5import * as WebTorrent from 'webtorrent'
6import { VideoFile } from '../../../../shared/models/videos/video.model' 6import { VideoFile } from '../../../../shared/models/videos/video.model'
7import { renderVideo } from './webtorrent/video-renderer' 7import { renderVideo } from './webtorrent/video-renderer'
8import { LoadedQualityData, VideoJSComponentInterface, WebtorrentPluginOptions } from './peertube-videojs-typings' 8import { LoadedQualityData, PlayerNetworkInfo, VideoJSComponentInterface, WebtorrentPluginOptions } from './peertube-videojs-typings'
9import { videoFileMaxByResolution, videoFileMinByResolution } from './utils' 9import { videoFileMaxByResolution, videoFileMinByResolution } from './utils'
10import { PeertubeChunkStore } from './webtorrent/peertube-chunk-store' 10import { PeertubeChunkStore } from './webtorrent/peertube-chunk-store'
11import { 11import {
@@ -180,7 +180,7 @@ class WebTorrentPlugin extends Plugin {
180 }) 180 })
181 181
182 this.changeQuality() 182 this.changeQuality()
183 this.trigger('videoFileUpdate', { auto: this.autoResolution, resolutionId: this.currentVideoFile.resolution.id }) 183 this.trigger('resolutionChange', { auto: this.autoResolution, resolutionId: this.currentVideoFile.resolution.id })
184 } 184 }
185 185
186 updateResolution (resolutionId: number, delay = 0) { 186 updateResolution (resolutionId: number, delay = 0) {
@@ -216,15 +216,15 @@ class WebTorrentPlugin extends Plugin {
216 216
217 enableAutoResolution () { 217 enableAutoResolution () {
218 this.autoResolution = true 218 this.autoResolution = true
219 this.trigger('videoFileUpdate', { auto: this.autoResolution, resolutionId: this.getCurrentResolutionId() }) 219 this.trigger('resolutionChange', { auto: this.autoResolution, resolutionId: this.getCurrentResolutionId() })
220 } 220 }
221 221
222 disableAutoResolution (forbid = false) { 222 disableAutoResolution (forbid = false) {
223 if (forbid === true) this.autoResolutionPossible = false 223 if (forbid === true) this.autoResolutionPossible = false
224 224
225 this.autoResolution = false 225 this.autoResolution = false
226 this.trigger('autoResolutionUpdate', { possible: this.autoResolutionPossible }) 226 this.trigger('autoResolutionChange', { possible: this.autoResolutionPossible })
227 this.trigger('videoFileUpdate', { auto: this.autoResolution, resolutionId: this.getCurrentResolutionId() }) 227 this.trigger('resolutionChange', { auto: this.autoResolution, resolutionId: this.getCurrentResolutionId() })
228 } 228 }
229 229
230 getTorrent () { 230 getTorrent () {
@@ -472,12 +472,14 @@ class WebTorrentPlugin extends Plugin {
472 if (this.webtorrent.downloadSpeed !== 0) this.downloadSpeeds.push(this.webtorrent.downloadSpeed) 472 if (this.webtorrent.downloadSpeed !== 0) this.downloadSpeeds.push(this.webtorrent.downloadSpeed)
473 473
474 return this.player.trigger('p2pInfo', { 474 return this.player.trigger('p2pInfo', {
475 downloadSpeed: this.torrent.downloadSpeed, 475 p2p: {
476 numPeers: this.torrent.numPeers, 476 downloadSpeed: this.torrent.downloadSpeed,
477 uploadSpeed: this.torrent.uploadSpeed, 477 numPeers: this.torrent.numPeers,
478 downloaded: this.torrent.downloaded, 478 uploadSpeed: this.torrent.uploadSpeed,
479 uploaded: this.torrent.uploaded 479 downloaded: this.torrent.downloaded,
480 }) 480 uploaded: this.torrent.uploaded
481 }
482 } as PlayerNetworkInfo)
481 }, this.CONSTANTS.INFO_SCHEDULER) 483 }, this.CONSTANTS.INFO_SCHEDULER)
482 } 484 }
483 485
@@ -597,7 +599,7 @@ class WebTorrentPlugin extends Plugin {
597 video: qualityLevelsPayload 599 video: qualityLevelsPayload
598 } 600 }
599 } 601 }
600 this.player.trigger('loadedqualitydata', payload) 602 this.player.tech_.trigger('loadedqualitydata', payload)
601 } 603 }
602 604
603 private buildQualityLabel (file: VideoFile) { 605 private buildQualityLabel (file: VideoFile) {