aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/src/assets/player/peertube-link-button.ts1
-rw-r--r--client/src/assets/player/peertube-videojs-plugin.ts17
-rw-r--r--client/src/assets/player/peertube-videojs-typings.ts2
-rw-r--r--client/src/assets/player/resolution-menu-item.ts1
-rw-r--r--client/src/assets/player/settings-menu-item.ts1
-rw-r--r--client/src/assets/player/utils.ts25
-rw-r--r--client/tsconfig.json3
-rw-r--r--client/webpack/webpack.video-embed.js7
8 files changed, 49 insertions, 8 deletions
diff --git a/client/src/assets/player/peertube-link-button.ts b/client/src/assets/player/peertube-link-button.ts
index 26f8b9d73..715207bc0 100644
--- a/client/src/assets/player/peertube-link-button.ts
+++ b/client/src/assets/player/peertube-link-button.ts
@@ -1,3 +1,4 @@
1import * as videojs from 'video.js'
1import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' 2import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
2import { buildVideoLink } from './utils' 3import { buildVideoLink } from './utils'
3 4
diff --git a/client/src/assets/player/peertube-videojs-plugin.ts b/client/src/assets/player/peertube-videojs-plugin.ts
index 9babe556a..b54f096b2 100644
--- a/client/src/assets/player/peertube-videojs-plugin.ts
+++ b/client/src/assets/player/peertube-videojs-plugin.ts
@@ -4,9 +4,16 @@ import { VideoFile } from '../../../../shared/models/videos/video.model'
4import { renderVideo } from './video-renderer' 4import { renderVideo } from './video-renderer'
5import './settings-menu-button' 5import './settings-menu-button'
6import { PeertubePluginOptions, VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' 6import { PeertubePluginOptions, VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
7import { getAverageBandwidth, getStoredMute, getStoredVolume, saveAverageBandwidth, saveMuteInStore, saveVolumeInStore } from './utils' 7import {
8import minBy from 'lodash-es/minBy' 8 getAverageBandwidth,
9import maxBy from 'lodash-es/maxBy' 9 getStoredMute,
10 getStoredVolume,
11 saveAverageBandwidth,
12 saveMuteInStore,
13 saveVolumeInStore,
14 videoFileMaxByResolution,
15 videoFileMinByResolution
16} from './utils'
10import * as CacheChunkStore from 'cache-chunk-store' 17import * as CacheChunkStore from 'cache-chunk-store'
11import { PeertubeChunkStore } from './peertube-chunk-store' 18import { PeertubeChunkStore } from './peertube-chunk-store'
12 19
@@ -339,9 +346,9 @@ class PeerTubePlugin extends Plugin {
339 }) 346 })
340 347
341 // If the download speed is too bad, return the lowest resolution we have 348 // If the download speed is too bad, return the lowest resolution we have
342 if (filteredFiles.length === 0) return minBy(this.videoFiles, 'resolution.id') 349 if (filteredFiles.length === 0) return videoFileMinByResolution(this.videoFiles)
343 350
344 return maxBy(filteredFiles, 'resolution.id') 351 return videoFileMaxByResolution(filteredFiles)
345 } 352 }
346 353
347 private getAndSaveActualDownloadSpeed () { 354 private getAndSaveActualDownloadSpeed () {
diff --git a/client/src/assets/player/peertube-videojs-typings.ts b/client/src/assets/player/peertube-videojs-typings.ts
index abdf333e1..50d6039ea 100644
--- a/client/src/assets/player/peertube-videojs-typings.ts
+++ b/client/src/assets/player/peertube-videojs-typings.ts
@@ -2,7 +2,7 @@ import * as videojs from 'video.js'
2import { VideoFile } from '../../../../shared/models/videos/video.model' 2import { VideoFile } from '../../../../shared/models/videos/video.model'
3import { PeerTubePlugin } from './peertube-videojs-plugin' 3import { PeerTubePlugin } from './peertube-videojs-plugin'
4 4
5declare module 'video.js' { 5declare namespace videojs {
6 interface Player { 6 interface Player {
7 peertube (): PeerTubePlugin 7 peertube (): PeerTubePlugin
8 } 8 }
diff --git a/client/src/assets/player/resolution-menu-item.ts b/client/src/assets/player/resolution-menu-item.ts
index 4b1ed0642..3fe1d8f0f 100644
--- a/client/src/assets/player/resolution-menu-item.ts
+++ b/client/src/assets/player/resolution-menu-item.ts
@@ -1,3 +1,4 @@
1import * as videojs from 'video.js'
1import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' 2import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
2 3
3const MenuItem: VideoJSComponentInterface = videojsUntyped.getComponent('MenuItem') 4const MenuItem: VideoJSComponentInterface = videojsUntyped.getComponent('MenuItem')
diff --git a/client/src/assets/player/settings-menu-item.ts b/client/src/assets/player/settings-menu-item.ts
index f595fd459..88985e1ae 100644
--- a/client/src/assets/player/settings-menu-item.ts
+++ b/client/src/assets/player/settings-menu-item.ts
@@ -1,6 +1,7 @@
1// Author: Yanko Shterev 1// Author: Yanko Shterev
2// Thanks https://github.com/yshterev/videojs-settings-menu 2// Thanks https://github.com/yshterev/videojs-settings-menu
3 3
4import * as videojs from 'video.js'
4import { toTitleCase } from './utils' 5import { toTitleCase } from './utils'
5import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' 6import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
6 7
diff --git a/client/src/assets/player/utils.ts b/client/src/assets/player/utils.ts
index ce7aaea2a..4eaf53720 100644
--- a/client/src/assets/player/utils.ts
+++ b/client/src/assets/player/utils.ts
@@ -1,4 +1,5 @@
1import { is18nLocale, isDefaultLocale } from '../../../../shared/models/i18n/i18n' 1import { is18nLocale, isDefaultLocale } from '../../../../shared/models/i18n/i18n'
2import { VideoFile } from '../../../../shared/models/videos'
2 3
3function toTitleCase (str: string) { 4function toTitleCase (str: string) {
4 return str.charAt(0).toUpperCase() + str.slice(1) 5 return str.charAt(0).toUpperCase() + str.slice(1)
@@ -97,6 +98,28 @@ function copyToClipboard (text: string) {
97 document.body.removeChild(el) 98 document.body.removeChild(el)
98} 99}
99 100
101function videoFileMaxByResolution (files: VideoFile[]) {
102 let max = files[0]
103
104 for (let i = 1; i < files.length; i++) {
105 const file = files[i]
106 if (max.resolution.id < file.resolution.id) max = file
107 }
108
109 return max
110}
111
112function videoFileMinByResolution (files: VideoFile[]) {
113 let min = files[0]
114
115 for (let i = 1; i < files.length; i++) {
116 const file = files[i]
117 if (min.resolution.id > file.resolution.id) min = file
118 }
119
120 return min
121}
122
100export { 123export {
101 toTitleCase, 124 toTitleCase,
102 buildVideoLink, 125 buildVideoLink,
@@ -107,6 +130,8 @@ export {
107 saveMuteInStore, 130 saveMuteInStore,
108 buildVideoEmbed, 131 buildVideoEmbed,
109 getStoredMute, 132 getStoredMute,
133 videoFileMaxByResolution,
134 videoFileMinByResolution,
110 copyToClipboard, 135 copyToClipboard,
111 isMobile, 136 isMobile,
112 bytes 137 bytes
diff --git a/client/tsconfig.json b/client/tsconfig.json
index 8ce9c5f96..cb6d39245 100644
--- a/client/tsconfig.json
+++ b/client/tsconfig.json
@@ -19,7 +19,8 @@
19 ], 19 ],
20 "baseUrl": "src", 20 "baseUrl": "src",
21 "paths": { 21 "paths": {
22 "@app/*": [ "app/*" ] 22 "@app/*": [ "app/*" ],
23 "video.js": [ "../node_modules/video.js/dist/alt/video.core.js" ]
23 } 24 }
24 } 25 }
25} 26}
diff --git a/client/webpack/webpack.video-embed.js b/client/webpack/webpack.video-embed.js
index 5a4e35dea..403a65930 100644
--- a/client/webpack/webpack.video-embed.js
+++ b/client/webpack/webpack.video-embed.js
@@ -1,4 +1,5 @@
1const helpers = require('./helpers') 1const helpers = require('./helpers')
2const path = require('path')
2 3
3const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin 4const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin
4const HtmlWebpackPlugin = require('html-webpack-plugin') 5const HtmlWebpackPlugin = require('html-webpack-plugin')
@@ -24,7 +25,11 @@ module.exports = function () {
24 */ 25 */
25 extensions: [ '.ts', '.js', '.json', '.scss' ], 26 extensions: [ '.ts', '.js', '.json', '.scss' ],
26 27
27 modules: [ helpers.root('src'), helpers.root('node_modules') ] 28 modules: [ helpers.root('src'), helpers.root('node_modules') ],
29
30 alias: {
31 'video.js$': path.resolve('node_modules/video.js/dist/alt/video.core.js')
32 }
28 }, 33 },
29 34
30 output: { 35 output: {