Skip to content

Commit

Permalink
Fix video throttling because of range header (#3234)
Browse files Browse the repository at this point in the history
* Fix video throttling because of range header

* Use a better way to extract the range
  • Loading branch information
absidue committed Mar 1, 2023
1 parent 4b25201 commit f56f6e7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/renderer/components/ft-video-player/ft-video-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ import { calculateColorLuminance, colors } from '../../helpers/colors'
import { pathExists } from '../../helpers/filesystem'
import { getPicturesPath, showSaveDialog, showToast } from '../../helpers/utils'

// YouTube now throttles if you use the `Range` header for the DASH formats, instead of the range query parameter
// videojs-http-streaming calls this hook everytime it makes a request,
// so we can use it to convert the Range header into the range query parameter for the streaming URLs
videojs.Vhs.xhr.beforeRequest = (options) => {
if (options.headers?.Range && new URL(options.uri).hostname.endsWith('.googlevideo.com')) {
options.uri += `&range=${options.headers.Range.split('=')[1]}`
delete options.headers.Range
}
}

export default defineComponent({
name: 'FtVideoPlayer',
props: {
Expand Down

0 comments on commit f56f6e7

Please sign in to comment.