desperately trying to fix the player's weirdness
This commit is contained in:
parent
5d1db70545
commit
4580ac3556
@ -28,6 +28,7 @@ let vidReady = false
|
||||
let shouldHide = true
|
||||
let inFullscreen = false
|
||||
let errored = false
|
||||
let live = false
|
||||
let ws
|
||||
|
||||
function GET (url, istext) {
|
||||
@ -81,7 +82,7 @@ function viewersCount (res) {
|
||||
viewers.innerHTML = res.length + ' watching'
|
||||
}
|
||||
|
||||
function handleWebSocket (live) {
|
||||
function handleWebSocket () {
|
||||
if (!live && ws) {
|
||||
ws.onerror = ws.onopen = ws.onclose = null
|
||||
ws.close()
|
||||
@ -89,13 +90,14 @@ function handleWebSocket (live) {
|
||||
return
|
||||
}
|
||||
|
||||
if (ws) return
|
||||
if (!live) return
|
||||
|
||||
ws = new WebSocket(`ws${location.protocol.indexOf('s') !== -1 ? 's' : ''}://${location.host}`)
|
||||
ws.onerror = function(e) {
|
||||
console.error('Socket errored, retrying..', e)
|
||||
handleWebSocket(false)
|
||||
setTimeout(() => handleWebSocket(vidReady), 5000)
|
||||
ws.close()
|
||||
ws = null
|
||||
setTimeout(() => handleWebSocket(), 5000)
|
||||
}
|
||||
|
||||
ws.onopen = function() {
|
||||
@ -116,11 +118,12 @@ function handleWebSocket (live) {
|
||||
ws.onclose = function() {
|
||||
console.error('Socket died, retrying..')
|
||||
ws = null
|
||||
setTimeout(() => handleWebSocket(vidReady), 5000)
|
||||
setTimeout(() => handleWebSocket(), 5000)
|
||||
}
|
||||
}
|
||||
|
||||
function liveStatus (status) {
|
||||
live = status
|
||||
if (status) {
|
||||
lstat.innerHTML = 'live now'
|
||||
lstat.className = 'badge live'
|
||||
|
Reference in New Issue
Block a user