mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Show record init errors.
This commit is contained in:
parent
7060c0e6d7
commit
302e9371c8
5 changed files with 38 additions and 5 deletions
|
@ -3248,6 +3248,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_record_lock_discard" = "Discard";
|
"lng_record_lock_discard" = "Discard";
|
||||||
"lng_record_voice_tip" = "Hold to record audio. Click to switch to video.";
|
"lng_record_voice_tip" = "Hold to record audio. Click to switch to video.";
|
||||||
"lng_record_video_tip" = "Hold to record video. Click to switch to audio.";
|
"lng_record_video_tip" = "Hold to record video. Click to switch to audio.";
|
||||||
|
"lng_record_audio_problem" = "Could not start audio recording. Please check your microphone.";
|
||||||
|
"lng_record_video_problem" = "Could not start video recording. Please check your camera.";
|
||||||
"lng_record_once_first_tooltip" = "Click to set this message to **Play Once**.";
|
"lng_record_once_first_tooltip" = "Click to set this message to **Play Once**.";
|
||||||
"lng_record_once_active_tooltip" = "The recipient will be able to listen only once.";
|
"lng_record_once_active_tooltip" = "The recipient will be able to listen only once.";
|
||||||
"lng_will_be_notified" = "Subscribers will be notified when you post.";
|
"lng_will_be_notified" = "Subscribers will be notified when you post.";
|
||||||
|
|
|
@ -2429,6 +2429,24 @@ void ComposeControls::initVoiceRecordBar() {
|
||||||
}
|
}
|
||||||
}, _wrap->lifetime());
|
}, _wrap->lifetime());
|
||||||
|
|
||||||
|
_voiceRecordBar->errors(
|
||||||
|
) | rpl::start_with_next([=](::Media::Capture::Error error) {
|
||||||
|
using Error = ::Media::Capture::Error;
|
||||||
|
switch (error) {
|
||||||
|
case Error::AudioInit:
|
||||||
|
case Error::AudioTimeout:
|
||||||
|
_show->showToast(tr::lng_record_audio_problem(tr::now));
|
||||||
|
break;
|
||||||
|
case Error::VideoInit:
|
||||||
|
case Error::VideoTimeout:
|
||||||
|
_show->showToast(tr::lng_record_video_problem(tr::now));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
_show->showToast(u"Unknown error."_q);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}, _wrap->lifetime());
|
||||||
|
|
||||||
_voiceRecordBar->updateSendButtonTypeRequests(
|
_voiceRecordBar->updateSendButtonTypeRequests(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
updateSendButtonType();
|
updateSendButtonType();
|
||||||
|
|
|
@ -50,9 +50,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace HistoryView::Controls {
|
namespace HistoryView::Controls {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using SendActionUpdate = VoiceRecordBar::SendActionUpdate;
|
|
||||||
using VoiceToSend = VoiceRecordBar::VoiceToSend;
|
|
||||||
|
|
||||||
constexpr auto kAudioVoiceUpdateView = crl::time(200);
|
constexpr auto kAudioVoiceUpdateView = crl::time(200);
|
||||||
constexpr auto kAudioVoiceMaxLength = 100 * 60; // 100 minutes
|
constexpr auto kAudioVoiceMaxLength = 100 * 60; // 100 minutes
|
||||||
constexpr auto kMaxSamples
|
constexpr auto kMaxSamples
|
||||||
|
@ -1703,8 +1700,9 @@ void VoiceRecordBar::startRecording() {
|
||||||
if (update.finished) {
|
if (update.finished) {
|
||||||
stop(update.samples >= kMinSamples);
|
stop(update.samples >= kMinSamples);
|
||||||
}
|
}
|
||||||
}, [=] {
|
}, [=](Error error) {
|
||||||
stop(false);
|
stop(false);
|
||||||
|
_errors.fire_copy(error);
|
||||||
}, _recordingLifetime);
|
}, _recordingLifetime);
|
||||||
}
|
}
|
||||||
_recordingLifetime.add([=] {
|
_recordingLifetime.add([=] {
|
||||||
|
@ -2025,6 +2023,10 @@ rpl::producer<> VoiceRecordBar::recordingTipRequests() const {
|
||||||
return _recordingTipRequests.events();
|
return _recordingTipRequests.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto VoiceRecordBar::errors() const -> rpl::producer<Error> {
|
||||||
|
return _errors.events();
|
||||||
|
}
|
||||||
|
|
||||||
bool VoiceRecordBar::isLockPresent() const {
|
bool VoiceRecordBar::isLockPresent() const {
|
||||||
return _lockShowing.current();
|
return _lockShowing.current();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,10 @@ namespace style {
|
||||||
struct RecordBar;
|
struct RecordBar;
|
||||||
} // namespace style
|
} // namespace style
|
||||||
|
|
||||||
|
namespace Media::Capture {
|
||||||
|
enum class Error : uchar;
|
||||||
|
} // namespace Media::Capture
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class AbstractButton;
|
class AbstractButton;
|
||||||
class SendButton;
|
class SendButton;
|
||||||
|
@ -57,6 +61,7 @@ public:
|
||||||
using SendActionUpdate = Controls::SendActionUpdate;
|
using SendActionUpdate = Controls::SendActionUpdate;
|
||||||
using VoiceToSend = Controls::VoiceToSend;
|
using VoiceToSend = Controls::VoiceToSend;
|
||||||
using FilterCallback = Fn<bool()>;
|
using FilterCallback = Fn<bool()>;
|
||||||
|
using Error = ::Media::Capture::Error;
|
||||||
|
|
||||||
VoiceRecordBar(
|
VoiceRecordBar(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
|
@ -88,6 +93,7 @@ public:
|
||||||
[[nodiscard]] rpl::producer<not_null<QEvent*>> lockViewportEvents() const;
|
[[nodiscard]] rpl::producer<not_null<QEvent*>> lockViewportEvents() const;
|
||||||
[[nodiscard]] rpl::producer<> updateSendButtonTypeRequests() const;
|
[[nodiscard]] rpl::producer<> updateSendButtonTypeRequests() const;
|
||||||
[[nodiscard]] rpl::producer<> recordingTipRequests() const;
|
[[nodiscard]] rpl::producer<> recordingTipRequests() const;
|
||||||
|
[[nodiscard]] rpl::producer<Error> errors() const;
|
||||||
|
|
||||||
void requestToSendWithOptions(Api::SendOptions options);
|
void requestToSendWithOptions(Api::SendOptions options);
|
||||||
|
|
||||||
|
@ -173,6 +179,7 @@ private:
|
||||||
rpl::event_stream<VoiceToSend> _sendVoiceRequests;
|
rpl::event_stream<VoiceToSend> _sendVoiceRequests;
|
||||||
rpl::event_stream<> _cancelRequests;
|
rpl::event_stream<> _cancelRequests;
|
||||||
rpl::event_stream<> _listenChanges;
|
rpl::event_stream<> _listenChanges;
|
||||||
|
rpl::event_stream<Error> _errors;
|
||||||
|
|
||||||
int _centerY = 0;
|
int _centerY = 0;
|
||||||
QRect _redCircleRect;
|
QRect _redCircleRect;
|
||||||
|
|
|
@ -26,7 +26,8 @@ constexpr auto kUpdateEach = crl::time(100);
|
||||||
constexpr auto kAudioFrequency = 48'000;
|
constexpr auto kAudioFrequency = 48'000;
|
||||||
constexpr auto kAudioBitRate = 32'000;
|
constexpr auto kAudioBitRate = 32'000;
|
||||||
constexpr auto kVideoBitRate = 3 * 1024 * 1024;
|
constexpr auto kVideoBitRate = 3 * 1024 * 1024;
|
||||||
constexpr auto kMaxDuration = 10 * crl::time(1000);
|
constexpr auto kMinDuration = crl::time(200);
|
||||||
|
constexpr auto kMaxDuration = 60 * crl::time(1000);
|
||||||
constexpr auto kInitTimeout = 5 * crl::time(1000);
|
constexpr auto kInitTimeout = 5 * crl::time(1000);
|
||||||
|
|
||||||
using namespace FFmpeg;
|
using namespace FFmpeg;
|
||||||
|
@ -384,6 +385,9 @@ RoundVideoResult RoundVideoRecorder::Private::finish() {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
finishEncoding();
|
finishEncoding();
|
||||||
|
if (_resultDuration < kMinDuration) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
.content = _result,
|
.content = _result,
|
||||||
.waveform = QByteArray(),
|
.waveform = QByteArray(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue