UI: Show warning if starting/stopping broadcast fails

This commit is contained in:
derrod 2021-10-13 10:53:59 +02:00
parent bd45d46c3c
commit 2170a6b8ac
2 changed files with 41 additions and 2 deletions

View file

@ -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<br/><br/>If this error persists <a href='https://studio.youtube.com/video/%2/livestreaming'>open the broadcast in YouTube Studio</a> 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.<br>
# YouTube API errors in format "YouTube.Errors.<error reason>"
YouTube.Errors.liveStreamingNotEnabled="Live streaming is not enabled on the selected YouTube channel.<br/><br/>See <a href='https://www.youtube.com/features'>youtube.com/features</a> for more information."
YouTube.Errors.livePermissionBlocked="Live streaming is unavailable on the selected YouTube Channel.<br/>Please note that it may take up to 24 hours for live streaming to become available after enabling it in your channel settings.<br/><br/>See <a href='https://www.youtube.com/features'>youtube.com/features</a> 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."

View file

@ -6364,7 +6364,24 @@ void OBSBasic::BroadcastButtonClicked()
std::shared_ptr<YoutubeApiWrappers> ytAuth =
dynamic_pointer_cast<YoutubeApiWrappers>(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<YoutubeApiWrappers> ytAuth =
dynamic_pointer_cast<YoutubeApiWrappers>(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;