Pick average video file insead of max quality

This commit is contained in:
Chocobozzz 2018-06-07 17:51:25 +02:00
parent 54d9d09bb1
commit 8eb8bc201e
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 9 additions and 3 deletions

View File

@ -147,7 +147,7 @@ class PeerTubePlugin extends Plugin {
const savedAverageBandwidth = getAverageBandwidth() const savedAverageBandwidth = getAverageBandwidth()
videoFile = savedAverageBandwidth videoFile = savedAverageBandwidth
? this.getAppropriateFile(savedAverageBandwidth) ? this.getAppropriateFile(savedAverageBandwidth)
: this.videoFiles[0] : this.pickAverageVideoFile()
} }
// Don't add the same video file once again // Don't add the same video file once again
@ -377,7 +377,7 @@ class PeerTubePlugin extends Plugin {
} else { } else {
// Don't try on iOS that does not support MediaSource // Don't try on iOS that does not support MediaSource
if (this.isIOS()) { if (this.isIOS()) {
this.currentVideoFile = this.videoFiles[0] this.currentVideoFile = this.pickAverageVideoFile()
return this.fallbackToHttp(undefined, false) return this.fallbackToHttp(undefined, false)
} }
@ -533,6 +533,12 @@ class PeerTubePlugin extends Plugin {
settingsDialog.on('mouseleave', () => enableInactivity()) 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 // Thanks: https://github.com/videojs/video.js/issues/4460#issuecomment-312861657
private initSmoothProgressBar () { private initSmoothProgressBar () {
const SeekBar = videojsUntyped.getComponent('SeekBar') const SeekBar = videojsUntyped.getComponent('SeekBar')

View File

@ -85,7 +85,7 @@ async function onVideoFileOptimizerSuccess (video: VideoModel, isNewVideo: boole
if (!videoDatabase) return undefined if (!videoDatabase) return undefined
if (video.privacy !== VideoPrivacy.PRIVATE) { if (video.privacy !== VideoPrivacy.PRIVATE) {
if (isNewVideo === true) { if (isNewVideo !== false) {
// Now we'll add the video's meta data to our followers // Now we'll add the video's meta data to our followers
await sequelizeTypescript.transaction(async t => { await sequelizeTypescript.transaction(async t => {
await sendCreateVideo(video, t) await sendCreateVideo(video, t)