Better error handling for streams

Also use older youtubeStreamKey as it appears our jitsi doesn't
support the newer one.
This commit is contained in:
David Baker 2021-03-04 17:52:49 +00:00
parent 63944b9f6d
commit 0f1b7a001e
3 changed files with 18 additions and 5 deletions

View file

@ -39,14 +39,14 @@ async function createLiveStream(roomId: string) {
}),
});
const respBody = response.json();
const respBody = await response.json();
return respBody['stream_id'];
}
export async function startJitsiAudioLivestream(widgetMessaging: ClientWidgetApi, roomId: string) {
const streamId = await createLiveStream(roomId);
widgetMessaging.transport.send(ElementWidgetActions.StartLiveStream, {
rtmpStreamKey: 'audioStream:' + streamId,
await widgetMessaging.transport.send(ElementWidgetActions.StartLiveStream, {
rtmpStreamKey: 'rtmp://audiostream.dummy/' + streamId,
});
}

View file

@ -28,6 +28,7 @@ import dis from "../../../dispatcher/dispatcher";
import SettingsStore from "../../../settings/SettingsStore";
import Modal from "../../../Modal";
import QuestionDialog from "../dialogs/QuestionDialog";
import ErrorDialog from "../dialogs/ErrorDialog";
import {WidgetType} from "../../../widgets/WidgetType";
import MatrixClientContext from "../../../contexts/MatrixClientContext";
import { Container, WidgetLayoutStore } from "../../../stores/widgets/WidgetLayoutStore";
@ -57,8 +58,18 @@ const WidgetContextMenu: React.FC<IProps> = ({
let streamAudioStreamButton;
if (getConfigLivestreamUrl() && (app.type === "m.jitsi" || app.type === "jitsi")) {
const onStreamAudioClick = () => {
startJitsiAudioLivestream(widgetMessaging, roomId);
const onStreamAudioClick = async () => {
try {
await startJitsiAudioLivestream(widgetMessaging, roomId);
} catch (err) {
console.log("Failed to start livestream", err);
// XXX: won't i18n well, but looks like widget api only support 'message'?
const message = err.message || _t("Unable to start audio streaming.");
Modal.createTrackedDialog('WidgetContext Menu', 'Livestream failed', ErrorDialog, {
title: _t('Failed to start livestream'),
description: message,
});
}
onFinished();
};
streamAudioStreamButton = <IconizedContextMenuOption

View file

@ -2357,6 +2357,8 @@
"Set status": "Set status",
"Set a new status...": "Set a new status...",
"View Community": "View Community",
"Failed to start livestream": "Failed to start livestream",
"Unable to start audio streaming.": "Unable to start audio streaming.",
"Start audio stream": "Start audio stream",
"Take a picture": "Take a picture",
"Delete Widget": "Delete Widget",