aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/shared
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-06 10:40:09 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-10-06 11:03:09 +0200
commitaa8b6df4a51c82eb91e6fd71a090b2128098af6b (patch)
treeb2d6292ceb34ad71a1ce9b671f0d87923f6c7c21 /client/src/app/videos/shared
parent127d96b969891a73d76e257581e5fd81cd867480 (diff)
downloadPeerTube-aa8b6df4a51c82eb91e6fd71a090b2128098af6b.tar.gz
PeerTube-aa8b6df4a51c82eb91e6fd71a090b2128098af6b.tar.zst
PeerTube-aa8b6df4a51c82eb91e6fd71a090b2128098af6b.zip
Client: handle multiple file resolutions
Diffstat (limited to 'client/src/app/videos/shared')
-rw-r--r--client/src/app/videos/shared/video.model.ts15
1 files changed, 12 insertions, 3 deletions
diff --git a/client/src/app/videos/shared/video.model.ts b/client/src/app/videos/shared/video.model.ts
index 17f41059d..b315e59b1 100644
--- a/client/src/app/videos/shared/video.model.ts
+++ b/client/src/app/videos/shared/video.model.ts
@@ -1,5 +1,6 @@
1import { Video as VideoServerModel, VideoFile } from '../../../../../shared' 1import { Video as VideoServerModel, VideoFile } from '../../../../../shared'
2import { User } from '../../shared' 2import { User } from '../../shared'
3import { VideoResolution } from '../../../../../shared/models/videos/video-resolution.enum'
3 4
4export class Video implements VideoServerModel { 5export class Video implements VideoServerModel {
5 author: string 6 author: string
@@ -116,11 +117,19 @@ export class Video implements VideoServerModel {
116 return (this.nsfw && (!user || user.displayNSFW === false)) 117 return (this.nsfw && (!user || user.displayNSFW === false))
117 } 118 }
118 119
119 getDefaultMagnetUri () { 120 getAppropriateMagnetUri (actualDownloadSpeed = 0) {
120 if (this.files === undefined || this.files.length === 0) return '' 121 if (this.files === undefined || this.files.length === 0) return ''
122 if (this.files.length === 1) return this.files[0].magnetUri
121 123
122 // TODO: choose the original file 124 // Find first video that is good for our download speed (remember they are sorted)
123 return this.files[0].magnetUri 125 let betterResolutionFile = this.files.find(f => actualDownloadSpeed > (f.size / this.duration))
126
127 // If the download speed is too bad, return the lowest resolution we have
128 if (betterResolutionFile === undefined) {
129 betterResolutionFile = this.files.find(f => f.resolution === VideoResolution.H_240P)
130 }
131
132 return betterResolutionFile.magnetUri
124 } 133 }
125 134
126 patch (values: Object) { 135 patch (values: Object) {