]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Pick average video file insead of max quality
authorChocobozzz <me@florianbigard.com>
Thu, 7 Jun 2018 15:51:25 +0000 (17:51 +0200)
committerChocobozzz <me@florianbigard.com>
Thu, 7 Jun 2018 15:57:11 +0000 (17:57 +0200)
client/src/assets/player/peertube-videojs-plugin.ts
server/lib/job-queue/handlers/video-file.ts

index b54f096b26770cee9886c8b28e88d0df637f91a6..e68d79e40e20400692ab1149958be3f49ab1149b 100644 (file)
@@ -147,7 +147,7 @@ class PeerTubePlugin extends Plugin {
       const savedAverageBandwidth = getAverageBandwidth()
       videoFile = savedAverageBandwidth
         ? this.getAppropriateFile(savedAverageBandwidth)
-        : this.videoFiles[0]
+        : this.pickAverageVideoFile()
     }
 
     // Don't add the same video file once again
@@ -377,7 +377,7 @@ class PeerTubePlugin extends Plugin {
     } else {
       // Don't try on iOS that does not support MediaSource
       if (this.isIOS()) {
-        this.currentVideoFile = this.videoFiles[0]
+        this.currentVideoFile = this.pickAverageVideoFile()
         return this.fallbackToHttp(undefined, false)
       }
 
@@ -533,6 +533,12 @@ class PeerTubePlugin extends Plugin {
     settingsDialog.on('mouseleave', () => enableInactivity())
   }
 
+  private pickAverageVideoFile () {
+    if (this.videoFiles.length === 1) return this.videoFiles[0]
+
+    return this.videoFiles[Math.floor(this.videoFiles.length / 2)]
+  }
+
   // Thanks: https://github.com/videojs/video.js/issues/4460#issuecomment-312861657
   private initSmoothProgressBar () {
     const SeekBar = videojsUntyped.getComponent('SeekBar')
index a6fce42790d904d1d7c1f96302b791602a7ab1bd..85f7dbfc2b83480f149e70d6f7144ec9219d4df6 100644 (file)
@@ -85,7 +85,7 @@ async function onVideoFileOptimizerSuccess (video: VideoModel, isNewVideo: boole
   if (!videoDatabase) return undefined
 
   if (video.privacy !== VideoPrivacy.PRIVATE) {
-    if (isNewVideo === true) {
+    if (isNewVideo !== false) {
       // Now we'll add the video's meta data to our followers
       await sequelizeTypescript.transaction(async t => {
         await sendCreateVideo(video, t)