Show in the UI how long the user has been streaming for. Closes #59

This commit is contained in:
Gabe Kangas
2020-07-18 15:06:54 -07:00
parent addfce2ec9
commit 8ba0b6d7ce
6 changed files with 49 additions and 14 deletions

View File

@@ -223,8 +223,26 @@ class Owncast {
}
this.streamStatus = status;
this.setCurrentStreamDuration();
};
setCurrentStreamDuration() {
// If we're offline then don't update any of the UI.
if (!this.streamStatus.online) {
return;
}
// Default to something
let streamDurationString = ""
if (this.streamStatus.online && this.streamStatus.lastConnectTime) {
const diff = (Date.now() - Date.parse(this.streamStatus.lastConnectTime)) / 1000;
streamDurationString = secondsToHMMSS(diff);
}
this.vueApp.streamStatus = `${MESSAGE_ONLINE} ${streamDurationString}.`
}
handleNetworkingError(error) {
console.log(`>>> App Error: ${error}`)
};
@@ -252,6 +270,8 @@ class Owncast {
clearTimeout(this.disableChatTimer);
this.disableChatTimer = null;
this.messagingInterface.enableChat();
setInterval(this.setCurrentStreamDuration.bind(this), 1000);
}
// when videojs player is ready, start polling for stream