import Hls from 'hls.js'

import { readToken } from 'helpers/token'

export const streamConfig: Partial<Hls.Config> = {
  liveSyncDuration: 30,
  maxBufferLength: 30,
  xhrSetup: (xhr, urlString) => {
    const url = new URL(urlString)
    url.searchParams.set('access_token', readToken() || '')
    xhr.open('GET', url.toString())
  },
}
