From 2170a6b8ac4b0c29c7f475e35244f3563447cedb Mon Sep 17 00:00:00 2001 From: derrod Date: Wed, 13 Oct 2021 10:53:59 +0200 Subject: [PATCH] UI: Show warning if starting/stopping broadcast fails --- UI/data/locale/en-US.ini | 7 +++++++ UI/window-basic-main.cpp | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/UI/data/locale/en-US.ini b/UI/data/locale/en-US.ini index 5586a7301..da98079a0 100644 --- a/UI/data/locale/en-US.ini +++ b/UI/data/locale/en-US.ini @@ -394,6 +394,8 @@ Output.BadPath.Text="The configured file output path is invalid. Please check yo # broadcast setup messages Output.NoBroadcast.Title="No Broadcast Configured" Output.NoBroadcast.Text="You need to set up a broadcast before you can start streaming." +Output.BroadcastStartFailed="Failed to start broadcast" +Output.BroadcastStopFailed="Failed to stop broadcast" # log upload dialog text and messages LogReturnDialog="Log Upload Successful" @@ -1248,6 +1250,8 @@ YouTube.Actions.Error.BroadcastNotFound="The selected broadcast was not found." YouTube.Actions.Error.FileMissing="Selected file does not exist." YouTube.Actions.Error.FileOpeningFailed="Failed opening selected file." YouTube.Actions.Error.FileTooLarge="Selected file is too large (Limit: 2 MiB)." +YouTube.Actions.Error.BroadcastTransitionFailed="Transitioning the broadcast failed: %1

If this error persists open the broadcast in YouTube Studio and try manually." +YouTube.Actions.Error.BroadcastTestStarting="Broadcast is transitioning to the test stage, this can take some time. Please try again in 10-30 seconds." YouTube.Actions.EventsLoading="Loading list of events..." YouTube.Actions.EventCreated.Title="Event Created" @@ -1268,3 +1272,6 @@ YouTube.Actions.AutoStopStreamingWarning="You will not be able to reconnect.
# YouTube API errors in format "YouTube.Errors." YouTube.Errors.liveStreamingNotEnabled="Live streaming is not enabled on the selected YouTube channel.

See youtube.com/features for more information." YouTube.Errors.livePermissionBlocked="Live streaming is unavailable on the selected YouTube Channel.
Please note that it may take up to 24 hours for live streaming to become available after enabling it in your channel settings.

See youtube.com/features for details." +YouTube.Errors.errorExecutingTransition="Transition failed due to a backend error. Please try again in a few seconds." +YouTube.Errors.errorStreamInactive="YouTube is not receiving data for your stream. Please check your configuration and try again." +YouTube.Errors.invalidTransition="The attempted transition was invalid. This may be due to the stream not having finished a previous transition. Please wait a few seconds and try again." diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index 557286115..e17a78bb9 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -6364,7 +6364,24 @@ void OBSBasic::BroadcastButtonClicked() std::shared_ptr ytAuth = dynamic_pointer_cast(auth); if (ytAuth.get()) { - ytAuth->StartLatestBroadcast(); + if (!ytAuth->StartLatestBroadcast()) { + auto last_error = ytAuth->GetLastError(); + if (last_error.isEmpty()) + last_error = QTStr( + "YouTube.Actions.Error.YouTubeApi"); + if (!ytAuth->GetTranslatedError(last_error)) + last_error = + QTStr("YouTube.Actions.Error.BroadcastTransitionFailed") + .arg(last_error, + ytAuth->GetBroadcastId()); + + OBSMessageBox::warning( + this, + QTStr("Output.BroadcastStartFailed"), + last_error, true); + ui->broadcastButton->setChecked(false); + return; + } } #endif broadcastActive = true; @@ -6402,7 +6419,22 @@ void OBSBasic::BroadcastButtonClicked() std::shared_ptr ytAuth = dynamic_pointer_cast(auth); if (ytAuth.get()) { - ytAuth->StopLatestBroadcast(); + if (!ytAuth->StopLatestBroadcast()) { + auto last_error = ytAuth->GetLastError(); + if (last_error.isEmpty()) + last_error = QTStr( + "YouTube.Actions.Error.YouTubeApi"); + if (!ytAuth->GetTranslatedError(last_error)) + last_error = + QTStr("YouTube.Actions.Error.BroadcastTransitionFailed") + .arg(last_error, + ytAuth->GetBroadcastId()); + + OBSMessageBox::warning( + this, + QTStr("Output.BroadcastStopFailed"), + last_error, true); + } } #endif broadcastActive = false;