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())
  },
}

export const REWIND_SECONDS = 5

export const HOUR_IN_MILLISECONDS = 60 * 60 * 1000
