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 shouldHide = true
|
||||||
let inFullscreen = false
|
let inFullscreen = false
|
||||||
let errored = false
|
let errored = false
|
||||||
|
let live = false
|
||||||
let ws
|
let ws
|
||||||
|
|
||||||
function GET (url, istext) {
|
function GET (url, istext) {
|
||||||
@ -81,7 +82,7 @@ function viewersCount (res) {
|
|||||||
viewers.innerHTML = res.length + ' watching'
|
viewers.innerHTML = res.length + ' watching'
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleWebSocket (live) {
|
function handleWebSocket () {
|
||||||
if (!live && ws) {
|
if (!live && ws) {
|
||||||
ws.onerror = ws.onopen = ws.onclose = null
|
ws.onerror = ws.onopen = ws.onclose = null
|
||||||
ws.close()
|
ws.close()
|
||||||
@ -89,13 +90,14 @@ function handleWebSocket (live) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ws) return
|
if (!live) return
|
||||||
|
|
||||||
ws = new WebSocket(`ws${location.protocol.indexOf('s') !== -1 ? 's' : ''}://${location.host}`)
|
ws = new WebSocket(`ws${location.protocol.indexOf('s') !== -1 ? 's' : ''}://${location.host}`)
|
||||||
ws.onerror = function(e) {
|
ws.onerror = function(e) {
|
||||||
console.error('Socket errored, retrying..', e)
|
console.error('Socket errored, retrying..', e)
|
||||||
handleWebSocket(false)
|
ws.close()
|
||||||
setTimeout(() => handleWebSocket(vidReady), 5000)
|
ws = null
|
||||||
|
setTimeout(() => handleWebSocket(), 5000)
|
||||||
}
|
}
|
||||||
|
|
||||||
ws.onopen = function() {
|
ws.onopen = function() {
|
||||||
@ -116,11 +118,12 @@ function handleWebSocket (live) {
|
|||||||
ws.onclose = function() {
|
ws.onclose = function() {
|
||||||
console.error('Socket died, retrying..')
|
console.error('Socket died, retrying..')
|
||||||
ws = null
|
ws = null
|
||||||
setTimeout(() => handleWebSocket(vidReady), 5000)
|
setTimeout(() => handleWebSocket(), 5000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function liveStatus (status) {
|
function liveStatus (status) {
|
||||||
|
live = status
|
||||||
if (status) {
|
if (status) {
|
||||||
lstat.innerHTML = 'live now'
|
lstat.innerHTML = 'live now'
|
||||||
lstat.className = 'badge live'
|
lstat.className = 'badge live'
|
||||||
|
Reference in New Issue
Block a user