0

Fix error in video embed. Closes #1687

This commit is contained in:
Gabe Kangas 2022-01-20 14:18:51 -08:00
parent a621e920e7
commit dbf9776a6e
No known key found for this signature in database
GPG Key ID: 9A56337728BC81EA
2 changed files with 17 additions and 6 deletions

View File

@ -1837,8 +1837,7 @@
"esprima": "^4.0.1",
"estraverse": "^5.2.0",
"esutils": "^2.0.2",
"optionator": "^0.8.1",
"source-map": "~0.6.1"
"optionator": "^0.8.1"
},
"bin": {
"escodegen": "bin/escodegen.js",
@ -1979,7 +1978,6 @@
"integrity": "sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==",
"dev": true,
"dependencies": {
"@types/yauzl": "^2.9.1",
"debug": "^4.1.1",
"get-stream": "^5.1.0",
"yauzl": "^2.10.0"
@ -2915,7 +2913,6 @@
"@types/node": "*",
"anymatch": "^3.0.3",
"fb-watchman": "^2.0.0",
"fsevents": "^2.3.2",
"graceful-fs": "^4.2.4",
"jest-regex-util": "^27.0.6",
"jest-serializer": "^27.0.6",

View File

@ -9,6 +9,7 @@ import {
addNewlines,
makeLastOnlineString,
pluralize,
parseSecondsToDurationString,
} from './utils/helpers.js';
import {
URL_CONFIG,
@ -47,6 +48,7 @@ export default class VideoOnly extends Component {
this.handleOfflineMode = this.handleOfflineMode.bind(this);
this.handleOnlineMode = this.handleOnlineMode.bind(this);
this.setCurrentStreamDuration = this.setCurrentStreamDuration.bind(this);
// player events
this.handlePlayerReady = this.handlePlayerReady.bind(this);
@ -139,7 +141,7 @@ export default class VideoOnly extends Component {
if (!status) {
return;
}
const { viewerCount, online, lastDisconnectTime } = status;
const { viewerCount, online, lastConnectTime, lastDisconnectTime } = status;
if (status.online && !curStreamOnline) {
// stream has just come online.
@ -152,6 +154,7 @@ export default class VideoOnly extends Component {
viewerCount,
streamOnline: online,
lastDisconnectTime,
lastConnectTime,
});
}
@ -191,6 +194,17 @@ export default class VideoOnly extends Component {
});
}
setCurrentStreamDuration() {
let streamDurationString = '';
if (this.state.lastConnectTime) {
const diff = (Date.now() - Date.parse(this.state.lastConnectTime)) / 1000;
streamDurationString = parseSecondsToDurationString(diff);
}
this.setState({
streamStatusMessage: `${MESSAGE_ONLINE} ${streamDurationString}`,
});
}
// play video!
handleOnlineMode() {
this.player.startPlayer();
@ -208,7 +222,7 @@ export default class VideoOnly extends Component {
}
handleNetworkingError(error) {
console.log(`>>> App Error: ${error}`);
console.error(`>>> App Error: ${error}`);
}
render(props, state) {