]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/assets/player/peertube-videojs-plugin.ts
Add title in player peers info to show total downloaded/uploaded data
[github/Chocobozzz/PeerTube.git] / client / src / assets / player / peertube-videojs-plugin.ts
index fe9fc1a696ffad27cdbe20e10aed5c4842ad93b4..fc07c35d61eca44fdead9fb29d2d9b21bd8720ec 100644 (file)
@@ -4,18 +4,17 @@ import { VideoFile } from '../../../../shared/models/videos/video.model'
 import { renderVideo } from './video-renderer'
 import './settings-menu-button'
 import { PeertubePluginOptions, VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
+import { isMobile, videoFileMaxByResolution, videoFileMinByResolution } from './utils'
+import * as CacheChunkStore from 'cache-chunk-store'
+import { PeertubeChunkStore } from './peertube-chunk-store'
 import {
-  getAverageBandwidth,
+  getAverageBandwidthInStore,
   getStoredMute,
-  getStoredVolume, isMobile,
+  getStoredVolume,
   saveAverageBandwidth,
   saveMuteInStore,
-  saveVolumeInStore,
-  videoFileMaxByResolution,
-  videoFileMinByResolution
-} from './utils'
-import * as CacheChunkStore from 'cache-chunk-store'
-import { PeertubeChunkStore } from './peertube-chunk-store'
+  saveVolumeInStore
+} from './peertube-player-local-storage'
 
 const Plugin: VideoJSComponentInterface = videojs.getPlugin('plugin')
 class PeerTubePlugin extends Plugin {
@@ -148,7 +147,7 @@ class PeerTubePlugin extends Plugin {
   ) {
     // Automatically choose the adapted video file
     if (videoFile === undefined) {
-      const savedAverageBandwidth = getAverageBandwidth()
+      const savedAverageBandwidth = getAverageBandwidthInStore()
       videoFile = savedAverageBandwidth
         ? this.getAppropriateFile(savedAverageBandwidth)
         : this.pickAverageVideoFile()
@@ -467,7 +466,9 @@ class PeerTubePlugin extends Plugin {
       return this.trigger('torrentInfo', {
         downloadSpeed: this.torrent.downloadSpeed,
         numPeers: this.torrent.numPeers,
-        uploadSpeed: this.torrent.uploadSpeed
+        uploadSpeed: this.torrent.uploadSpeed,
+        downloaded: this.torrent.downloaded,
+        uploaded: this.torrent.uploaded
       })
     }, this.CONSTANTS.INFO_SCHEDULER)
   }
@@ -502,6 +503,8 @@ class PeerTubePlugin extends Plugin {
   }
 
   private addViewToVideo () {
+    if (!this.videoViewUrl) return Promise.resolve(undefined)
+
     return fetch(this.videoViewUrl, { method: 'POST' })
   }