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
2 changed files with 17 additions and 6 deletions

View File

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

View File

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